From 5fcf4c5233c8363919ab4f03cef711b923e9635c Mon Sep 17 00:00:00 2001 From: CJ_Clippy Date: Thu, 20 Feb 2025 17:44:35 -0800 Subject: [PATCH] note the nektos/act vs gitea act_runner network issue --- .gitea/workflows/tests.yaml | 42 +++++++++++++++++++++++++++---------- README.md | 16 +++++++------- 2 files changed, 40 insertions(+), 18 deletions(-) diff --git a/.gitea/workflows/tests.yaml b/.gitea/workflows/tests.yaml index 2f8cb43..f38a586 100644 --- a/.gitea/workflows/tests.yaml +++ b/.gitea/workflows/tests.yaml @@ -9,6 +9,17 @@ on: - cron: "6 */12 * * *" jobs: + # there is some undesirable behavior when running tests because nektos/act mimicks github actions. + # we are banned from github so we aren't using that. instead, we use gitea act_runner. + # github actions Job runner runs on docker 'host' network. + # gitea act_runner runs on a custom named bridge network. e.g. `GITEA-ACTIONS-TASK-974_WORKFLOW-ci_JOB-Tests-Checks-test_phoenix-network` + # confusing, right? It totally is! + # when we are working with gitea act_runner, we can use dns names, e.g. test-db. + # when we are working with nektos/act, we must use the IP address of the service container. + # this causes issues because nektos/act will not be able to find test-db:5432 but act_runner can. + # this means we have inconsistent behavior across testing environments, which is bad. + # our workaround is to use localhost on local dev, and the dns name on gitea act_runner. + test_phoenix: env: SECRET_KEY_BASE: ${{ secrets.SECRET_KEY_BASE }} @@ -37,14 +48,15 @@ jobs: pull-requests: write services: - db: + test-db: image: postgres:16 - ports: - - 5433:5432 env: POSTGRES_DB: ${{ vars.DB_NAME }} POSTGRES_USER: ${{ vars.DB_USER }} POSTGRES_PASSWORD: ${{ secrets.DB_PASS }} + PGUSER: ${{ vars.DB_USER }} + ports: + - 5433:5432 options: >- --health-cmd pg_isready --health-interval 10s @@ -98,6 +110,14 @@ jobs: user = "nobody" steps: + # I wasn't successful with this. Something about the docker network in which the container runs? + # - name: postgres service check + # env: + # PGPASSWORD: ${{ secrets.DB_PASS }} + # uses: docker://postgres:16 + # with: + # args: /usr/bin/pg_isready --host test-db --port 5432 + - name: Setup FFmpeg uses: FedericoCarboni/setup-ffmpeg@v3 @@ -122,14 +142,14 @@ jobs: 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: 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 diff --git a/README.md b/README.md index 2663eea..1746a25 100644 --- a/README.md +++ b/README.md @@ -41,11 +41,13 @@ Use devbox helper script cat ./backups/your-backup.sql | docker exec -i postgres_db psql -U postgres -## Metrics Notes - -Keeping track of metrics we want to scrape using Prometheus - - - - +## testing +there is some undesirable behavior when running tests because nektos/act mimicks github actions. +we are banned from github so we aren't using that. instead, we use gitea act_runner. +github actions Job runner runs on docker 'host' network. +gitea act_runner runs on a custom named bridge network. e.g. `GITEA-ACTIONS-TASK-974_WORKFLOW-ci_JOB-Tests-Checks-test_phoenix-network` +confusing, right? It totally is! +when we are working with gitea act_runner, we can use dns names, e.g. test-db. +when we are working with nektos/act, we must use the IP address of the service container. +WTF there must be a better way