fp/.gitea/workflows/tests.yaml
CJ_Clippy 2d8ca01ad1
Some checks failed
ci / build (push) Has been cancelled
ci / Tests & Checks (push) Failing after 15m34s
add opentracker svc check
2025-02-13 01:49:39 -08:00

168 lines
4.9 KiB
YAML

name: ci
on:
pull_request:
push:
branches:
- "main"
schedule:
- cron: "6 */12 * * *"
jobs:
# test_javascript:
# runs-on: ubuntu-latest
# environment: docker
# steps:
# - name: Check out code
# uses: actions/checkout@v3
# - name: Setup pnpm
# uses: pnpm/action-setup@v4
# with:
# run_install: |
# - recursive: true
# args: [--frozen-lockfile, --strict-peer-dependencies]
# - name: Unit test all packages
# run: pnpm test -r
test_phoenix:
name: Tests & Checks
runs-on: ubuntu-22.04
timeout-minutes: 600
permissions:
contents: read
pull-requests: write
env:
MIX_ENV: test
TRACKER_URL: http://localhost:8666/announce
WHITELIST_URL: ${{ vars. WHITELIST_URL }}
WHITELIST_USERNAME: ${{ secrets.WHITELIST_USERNAME }}
WHITELIST_PASSWORD: ${{ secrets.WHITELIST_PASSWORD }}
WHITELIST_PASSWORD_CADDY: ${{ secrets.WHITELIST_PASSWORD_CADDY }}
WHITELIST_FEED_URL: http://localhost:4000/torrents
AWS_BUCKET: ${{ vars.AWS_BUCKET }}
AWS_HOST: ${{ vars.AWS_HOST }}
AWS_REGION: ${{ vars.AWS_REGION }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
PUBLIC_S3_ENDPOINT: ${{ vars.PUBLIC_S3_ENDPOINT }}
SITE_URL: https://futureporn.net
SECRET_KEY_BASE: ${{ secrets.SECRET_KEY_BASE }}
# @blocking @see https://gitea.com/gitea/act_runner/issues/506
services:
db:
image: postgres:16
ports:
- 5432:5432
env:
POSTGRES_DB: ${{ vars.DB_NAME }}
POSTGRES_USER: ${{ vars.DB_USER }}
POSTGRES_PASSWORD: ${{ secrets.DB_PASS }}
opentracker:
image: gitea.futureporn.net/futureporn/opentracker:latest
ports:
- 8666:8666
env:
WHITELIST_USERNAME: ${{ secrets.WHITELIST_USERNAME }}
WHITELIST_PASSWORD_CADDY: ${{ secrets.WHITELIST_PASSWORD_CADDY }}
# @todo delete WHITELIST_PASSWORD ASAP. we're waiting for futureporn/opentracker to update
# We've corrected it to WHITELIST_PASSWORD_CADDY in the Caddyfile,
# but the change isn't live in the container yet.
WHITELIST_PASSWORD: ${{ secrets.WHITELIST_PASSWORD_CADDY }}
WHITELIST_FEED_URL: https://bright.futureporn.net/torrents
steps:
- name: Install apt packages
run: apt-get update && apt-get install -y iputils-ping postgresql
- name: Check opentracker pingability
run: ping -c 30 opentracker
- name: opentracker service check
run: curl http://opentracker:8666/stats
- name: Check postgres pingability
run: ping -c 3 db
- name: postgres service check
env:
PGPASSWORD: ${{ secrets.DB_PASS }}
run: psql --host=db --port=5432 --dbname=${{ vars.DB_NAME }} --username=${{ vars.DB_USER }} --list
- 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
- 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
with:
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
- name: Code coverage
run: |
mix coveralls
working-directory: ./apps/bright
- 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