fp/.gitea/workflows/tests.yaml

171 lines
4.7 KiB
YAML
Raw Normal View History

2024-06-15 11:51:53 -08:00
name: ci
on:
2025-02-10 08:16:50 -08:00
pull_request:
2024-06-15 11:51:53 -08:00
push:
branches:
2025-02-10 08:16:50 -08:00
- "main"
2024-06-15 11:51:53 -08:00
schedule:
2025-02-10 08:16:50 -08:00
- cron: "6 */12 * * *"
2024-06-15 11:51:53 -08:00
jobs:
2025-02-12 13:09:16 -08:00
test_phoenix:
2025-02-10 08:16:50 -08:00
name: Tests & Checks
runs-on: ubuntu-22.04
timeout-minutes: 600
permissions:
contents: read
pull-requests: write
env:
MIX_ENV: test
2025-02-13 02:52:55 -08:00
TRACKER_URL: ${{ vars.TRACKER_URL }}
WHITELIST_URL: ${{ vars.WHITELIST_URL }}
2025-02-10 08:16:50 -08:00
WHITELIST_USERNAME: ${{ secrets.WHITELIST_USERNAME }}
WHITELIST_PASSWORD: ${{ secrets.WHITELIST_PASSWORD }}
WHITELIST_PASSWORD_CADDY: ${{ secrets.WHITELIST_PASSWORD_CADDY }}
2025-02-13 02:52:55 -08:00
WHITELIST_FEED_URL: ${{ vars.WHITELIST_FEED_URL }}
2025-02-13 01:16:56 -08:00
AWS_BUCKET: ${{ vars.AWS_BUCKET }}
AWS_HOST: ${{ vars.AWS_HOST }}
AWS_REGION: ${{ vars.AWS_REGION }}
2025-02-10 08:16:50 -08:00
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
2025-02-13 01:16:56 -08:00
PUBLIC_S3_ENDPOINT: ${{ vars.PUBLIC_S3_ENDPOINT }}
2025-02-10 08:16:50 -08:00
SITE_URL: https://futureporn.net
2025-02-12 13:09:16 -08:00
SECRET_KEY_BASE: ${{ secrets.SECRET_KEY_BASE }}
2025-02-10 08:16:50 -08:00
services:
db:
image: postgres:16
ports:
- 5432:5432
env:
2025-02-13 00:11:43 -08:00
POSTGRES_DB: ${{ vars.DB_NAME }}
POSTGRES_USER: ${{ vars.DB_USER }}
2025-02-12 23:52:31 -08:00
POSTGRES_PASSWORD: ${{ secrets.DB_PASS }}
2025-02-10 08:16:50 -08:00
2025-02-15 04:31:20 -08:00
tracker-helper:
image: gitea.futureporn.net/futureporn/tracker-helper:latest
ports:
- 3000:3000
env:
WL_FIFO_PATH: /etc/opentracker/adder.fifo
WL_FILE_PATH: /etc/opentracker/whitelist
WL_CREDENTIALS: ${{ secrets.WL_CREDENTIALS }}
volumes:
- /tmp/futureporn/opentracker:/etc/opentracker
2025-02-10 08:16:50 -08:00
opentracker:
image: gitea.futureporn.net/futureporn/opentracker:latest
ports:
2025-02-15 04:31:20 -08:00
- 6969:6969
2025-02-10 08:16:50 -08:00
env:
WHITELIST_FEED_URL: https://bright.futureporn.net/torrents
2025-02-15 04:31:20 -08:00
volumes:
- /tmp/futureporn/opentracker:/etc/opentracker
2025-02-10 08:16:50 -08:00
2024-06-15 11:51:53 -08:00
steps:
2025-02-15 04:31:20 -08:00
- name: wait a few seconds
run: sleep 30
2025-02-12 22:57:43 -08:00
2025-02-15 04:31:20 -08:00
- name: Debug services
run: docker ps -a
2025-02-13 01:49:39 -08:00
2025-02-15 04:31:20 -08:00
# - name: Install apt packages
# run: apt-get update && apt-get install -y iputils-ping postgresql
- name: tracker-helper service check (localhost)
run: curl http://localhost:3000/health
- name: tracker-helper service check
run: curl http://tracker-helper:3000/health
2025-02-13 01:49:39 -08:00
2025-02-15 04:31:20 -08:00
# - name: Check opentracker pingability
# run: ping -c 3 opentracker
- name: opentracker service check
run: |
getent hosts opentracker
curl -v http://opentracker:6969/stats
2025-02-14 03:15:00 -08:00
2025-02-12 22:57:43 -08:00
- name: Check postgres pingability
run: ping -c 3 db
2025-02-12 22:42:44 -08:00
- name: postgres service check
2025-02-12 22:57:43 -08:00
env:
PGPASSWORD: ${{ secrets.DB_PASS }}
2025-02-13 00:39:04 -08:00
run: psql --host=db --port=5432 --dbname=${{ vars.DB_NAME }} --username=${{ vars.DB_USER }} --list
2025-02-12 22:42:44 -08:00
2025-02-10 08:16:50 -08:00
- name: Setup FFmpeg
uses: FedericoCarboni/setup-ffmpeg@v3
- name: Setup futureporn cache dir
run: |
mkdir -p ~/.cache/futureporn
- name: Setup PIP packages
uses: insightsengineering/pip-action@v2
with:
packages: |
torrentfile
2024-06-15 11:51:53 -08:00
2025-02-10 08:16:50 -08:00
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Erlang and Elixir
uses: erlef/setup-beam@v1.17
with:
elixir-version: "1.16.0-otp-26"
otp-version: "26.0"
- name: Mix and build cache
uses: actions/cache@v4
2024-06-15 12:12:01 -08:00
with:
2025-02-10 08:16:50 -08:00
path: |
deps
_build
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-mix-
- name: Get dependencies
run: mix deps.get
working-directory: ./apps/bright
- name: Code analyzers
run: |
mix format --check-formatted
mix compile --warnings-as-errors
working-directory: ./apps/bright
- name: Unit tests
run: |
mix test --only=unit
working-directory: ./apps/bright
- name: Integration tests
run: |
mix test --only=integration
working-directory: ./apps/bright
- name: Acceptance tests
run: |
mix test --only=acceptance
working-directory: ./apps/bright
- name: Uncategorized tests (ideally there should be none)
run: |
mix test --exclude=acceptance --exclude=unit --exclude=integration
working-directory: ./apps/bright
2024-06-15 12:03:31 -08:00
2025-02-10 08:16:50 -08:00
- name: Code coverage
run: |
mix coveralls
working-directory: ./apps/bright
2025-02-12 13:09:16 -08:00
- name: Check for banned HTML elements (i.e. <a>)
run: |
if grep -R '</a>' ./lib; then
echo "Found banned element '<a>' inside ./lib. Please use <.link> instead."
exit 1
fi
working-directory: ./apps/bright