-
Notifications
You must be signed in to change notification settings - Fork 1
62 lines (57 loc) · 1.83 KB
/
tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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') }}