feat: launch django & tests with keyboard interrupt #25
This file contains 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: "Test" | |
on: | |
pull_request: | |
branches: [ "master" ] | |
push: | |
branches: [ "master" ] | |
env: | |
SECRET_KEY: ${{ secrets.SECRET_KEY }} | |
jobs: | |
tests: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Restore python poetry dependencies from cache | |
uses: actions/cache/restore@v3 | |
id: cache | |
with: | |
path: ~/.cache/pypoetry | |
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }} | |
- uses: cachix/install-nix-action@v19 | |
with: | |
install_url: https://releases.nixos.org/nix/nix-2.13.3/install | |
- uses: cachix/cachix-action@v12 | |
with: | |
name: devenv | |
- name: Install devenv.sh | |
run: nix profile install github:cachix/devenv/v0.5 | |
shell: sh | |
- run: devenv ci | |
- name: Install dependencies | |
run: | | |
OUTPUT=$(devenv shell echo "Dependencies installed!") | |
# If poetry environment is broken then recache all Python dependencies ... | |
if [[ "$OUTPUT" == *"POETRY_STATUS=broken"* ]]; then | |
echo "POETRY_STATUS=broken" >> $GITHUB_ENV | |
else | |
echo "POETRY_STATUS=clean" >> $GITHUB_ENV | |
fi | |
echo $OUTPUT >> /tmp/dependencies.log | |
- name: Run tests | |
run: devenv shell test-all | |
- name: Show logs from dependency installation | |
if: always() | |
run: cat /tmp/dependencies.log | |
- name: Show logs from test database setup | |
if: always() | |
run: cat /tmp/devenv.log | |
- name: Show environment variables | |
if: always() | |
run: | | |
echo "POETRY_STATUS=${{ env.POETRY_STATUS }}" | |
- name: Cache python dependencies | |
uses: actions/cache/save@v3 | |
if: always() && steps.cache.outputs.cache-hit != 'true' || ${{ env.POETRY_STATUS }} == 'broken' | |
with: | |
path: ~/.cache/pypoetry | |
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }} |