diff --git a/.github/workflows/python-tests.yml b/.github/workflows/python-tests.yml index 36537db39..3ac7b5ee6 100644 --- a/.github/workflows/python-tests.yml +++ b/.github/workflows/python-tests.yml @@ -1,14 +1,14 @@ name: Python tests -on: [push, workflow_dispatch] +on: [ push, workflow_dispatch ] jobs: test: runs-on: ubuntu-22.04 strategy: - fail-fast: false matrix: - python-version: ["3.10.12"] + python-version: [ "3.10.12" ] + poetry-version: [ "1.8.3" ] # Service containers to run with `test` services: @@ -23,10 +23,6 @@ jobs: POSTGRES_PASSWORD: password # Set health checks to wait until postgres has started options: >- - --health-cmd pg_isready - --health-interval 10s - --health-timeout 5s - --health-retries 5 --name postgres ports: # Maps tcp port 5432 on service container to the host @@ -38,71 +34,60 @@ jobs: # Set health checks to wait until redis has started options: >- --health-cmd "redis-cli ping" - --health-interval 10s + --health-interval 5s --health-timeout 5s --health-retries 5 ports: # Maps tcp port 6379 on service container to the host - 6379:6379 steps: - - name: Increase max_connections - run: | - docker exec -i postgres bash << EOF - sed -i -e 's/max_connections = 100/max_connections = 10000/' /var/lib/postgresql/data/postgresql.conf - EOF - - name: Restart postgres - run: | - docker restart --time 0 postgres && sleep 5 - - - uses: actions/checkout@v4 -# with: -# submodules: recursive + # https://remarkablemark.org/blog/2022/05/12/github-actions-postgresql-increase-max-connections-and-shared-buffers/ + - name: Increase max_connections + run: >- + docker exec -i postgres bash << EOF + sed -i -e 's/max_connections = 100/max_connections = 10000/' /var/lib/postgresql/data/postgresql.conf + EOF + - name: Restart postgres + run: >- + docker restart postgres && while ! docker exec postgres pg_isready; do sleep 5; done - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - cache: 'pip' + - uses: actions/checkout@v4 - - name: Install system dependencies - run: | - sudo apt-get update && sudo apt-get install -y --no-install-recommends \ - libpoppler-cpp-dev \ - python3-opencv \ - postgresql-client \ - libzbar0 + - name: Install system dependencies + uses: awalsh128/cache-apt-pkgs-action@latest + with: + packages: libpoppler-cpp-dev python3-opencv postgresql-client libzbar0 + version: 1.0 - - name: Install python dependencies - run: | - pip install -U poetry pip && poetry install --only main --no-interaction + - name: Setup Python, Poetry and Dependencies + uses: packetcoders/action-setup-cache-python-poetry@main + with: + python-version: ${{matrix.python-version}} + poetry-version: ${{matrix.poetry-version}} + install-args: --only main --no-interaction -# - name: Load secrets into env -# uses: oNaiPs/secrets-to-env-action@v1 -# with: -# secrets: ${{ toJSON(secrets) }} - - - name: Test with pytest - env: - PGHOST: localhost - PGPORT: 5432 - PGDATABASE: gooey - PGUSER: postgres - PGPASSWORD: password - REDIS_URL: redis://localhost:6379/0 - REDIS_CACHE_URL: redis://localhost:6379/1 - APP_BASE_URL: http://localhost:3000 - API_BASE_URL: http://localhost:8080 - ADMIN_BASE_URL: http://localhost:8000 - GOOGLE_APPLICATION_CREDENTIALS_JSON: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS_JSON }} - GS_BUCKET_NAME: ${{ secrets.GS_BUCKET_NAME }} - STRIPE_SECRET_KEY: ${{ secrets.STRIPE_SECRET_KEY }} - ELEVEN_LABS_API_KEY: ${{ secrets.ELEVEN_LABS_API_KEY }} - AZURE_SPEECH_REGION: ${{ secrets.AZURE_SPEECH_REGION }} - AZURE_SPEECH_KEY: ${{ secrets.AZURE_SPEECH_KEY }} - AZURE_FORM_RECOGNIZER_ENDPOINT: ${{ secrets.AZURE_FORM_RECOGNIZER_ENDPOINT }} - AZURE_FORM_RECOGNIZER_KEY: ${{ secrets.AZURE_FORM_RECOGNIZER_KEY }} - TEST_SLACK_TEAM_ID: ${{ secrets.TEST_SLACK_TEAM_ID }} - TEST_SLACK_USER_ID: ${{ secrets.TEST_SLACK_USER_ID }} - TEST_SLACK_AUTH_TOKEN: ${{ secrets.TEST_SLACK_AUTH_TOKEN }} - run: | - poetry run ./scripts/run-tests.sh + - name: Run tests + env: + PGHOST: localhost + PGPORT: 5432 + PGDATABASE: gooey + PGUSER: postgres + PGPASSWORD: password + REDIS_URL: redis://localhost:6379/0 + REDIS_CACHE_URL: redis://localhost:6379/1 + APP_BASE_URL: http://localhost:3000 + API_BASE_URL: http://localhost:8080 + ADMIN_BASE_URL: http://localhost:8000 + GOOGLE_APPLICATION_CREDENTIALS_JSON: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS_JSON }} + GS_BUCKET_NAME: ${{ secrets.GS_BUCKET_NAME }} + STRIPE_SECRET_KEY: ${{ secrets.STRIPE_SECRET_KEY }} + ELEVEN_LABS_API_KEY: ${{ secrets.ELEVEN_LABS_API_KEY }} + AZURE_SPEECH_REGION: ${{ secrets.AZURE_SPEECH_REGION }} + AZURE_SPEECH_KEY: ${{ secrets.AZURE_SPEECH_KEY }} + AZURE_FORM_RECOGNIZER_ENDPOINT: ${{ secrets.AZURE_FORM_RECOGNIZER_ENDPOINT }} + AZURE_FORM_RECOGNIZER_KEY: ${{ secrets.AZURE_FORM_RECOGNIZER_KEY }} + TEST_SLACK_TEAM_ID: ${{ secrets.TEST_SLACK_TEAM_ID }} + TEST_SLACK_USER_ID: ${{ secrets.TEST_SLACK_USER_ID }} + TEST_SLACK_AUTH_TOKEN: ${{ secrets.TEST_SLACK_AUTH_TOKEN }} + run: | + poetry run ./scripts/run-tests.sh