Ensure that OpenAI key is available for tests #107
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Tests | |
| on: | |
| push: | |
| branches: [ main, master ] | |
| pull_request: | |
| branches: [ main, master ] | |
| workflow_call: | |
| secrets: | |
| LIS_KEY: | |
| required: false | |
| OPENAI_KEY: | |
| required: false | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out repo | |
| uses: actions/checkout@v4 | |
| - name: Start Docker services | |
| run: | | |
| docker compose up -d --build | |
| - name: Initialize application inside container | |
| run: | | |
| docker exec rs_machine /home/ubuntu/rs-machine/deploy/docker-setup.sh | |
| - name: Configure local settings overrides | |
| env: | |
| LIS_KEY_SECRET: ${{ secrets.LIS_KEY }} | |
| OPENAI_KEY_SECRET: ${{ secrets.OPENAI_KEY }} | |
| run: | | |
| { | |
| printf "%s\n" "<?php" | |
| [ -n "$LIS_KEY_SECRET" ] && printf "rs_define('LIS_KEY', '%s');\n" "${LIS_KEY_SECRET}" | |
| [ -n "$OPENAI_KEY_SECRET" ] && printf "rs_define('OPENAI_KEY', '%s');\n" "${OPENAI_KEY_SECRET}" | |
| } > settings.local.inc.php | |
| docker cp settings.local.inc.php rs_machine:/home/ubuntu/rs-machine/includes/settings.local.inc.php | |
| rm -f settings.local.inc.php | |
| - name: Run test suite | |
| run: | | |
| chmod +x docker-tests.sh | |
| ./docker-tests.sh | |
| - name: Shutdown Docker services | |
| if: always() | |
| run: | | |
| docker compose down -v |