-
Notifications
You must be signed in to change notification settings - Fork 72
120 lines (102 loc) · 5.47 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
name: Tests
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-22.04
# don't run on pushes to forks
if: github.event_name == 'pull_request' || github.repository == 'harvard-lil/perma'
steps:
- uses: actions/checkout@v2
### build docker images locally ###
- name: Rebuild docker images
id: rebuild
uses: harvard-lil/docker-compose-update-action@main
### prepare to install trusted self-signed SSL certs
- name: Install mkcert
# from https://computingforgeeks.com/create-locally-trusted-ssl-certificates-on-linux-macos-using-mkcert/
run: |
sudo apt-get update
sudo apt install wget libnss3-tools
curl -s https://api.github.com/repos/FiloSottile/mkcert/releases/latest | grep browser_download_url | grep linux-amd64 | cut -d '"' -f 4 | wget -qi -
mv mkcert-v*-linux-amd64 mkcert
chmod a+x mkcert
sudo mv mkcert /usr/local/bin/
mkcert -install
### run tests ###
- name: docker compose up
shell: 'script -q -e -c "bash --noprofile --norc -eo pipefail {0}"' # avoid docker-compose "the input device is not a TTY" -- see https://github.com/actions/runner/issues/241#issuecomment-842566950
run: |
# separate pull so downloads run in parallel, with
# --ignore-pull-failures for PRs with new images that haven't been pushed yet:
docker compose -f docker-compose.yml pull --ignore-pull-failures || true
docker compose -f docker-compose.yml up -d # use -f to suppress docker-compose.override.yml
docker compose up -d scoop-redis scoop-db scoop-rest-api # start up the Scoop API separately
bash make_cert.sh # install SSL certs and restart the wacz-exhibitor and minio containers
docker ps -a # show running containers
docker compose logs # show logs
- name: Javascript tests
shell: 'script -q -e -c "bash --noprofile --norc -eo pipefail {0}"' # avoid docker-compose "the input device is not a TTY" -- see https://github.com/actions/runner/issues/241#issuecomment-842566950
run: |
set -x
docker compose exec web npm run test
- name: Build and collect static files
shell: 'script -q -e -c "bash --noprofile --norc -eo pipefail {0}"' # avoid docker-compose "the input device is not a TTY" -- see https://github.com/actions/runner/issues/241#issuecomment-842566950
run: |
set -x
docker compose exec web npm run build # compile fresh bundles
docker compose exec web ./manage.py collectstatic --noinput # collect static files
- name: Python tests
shell: 'script -q -e -c "bash --noprofile --norc -eo pipefail {0}"' # avoid docker-compose "the input device is not a TTY" -- see https://github.com/actions/runner/issues/241#issuecomment-842566950
run: |
set -x
docker compose exec web invoke dev.init-db
docker compose exec web pytest \
--cov --cov-config=setup.cfg --cov-report xml `# write coverage data to .coverage for upload by codecov` \
-vv
### codecov ###
# https://github.com/codecov/codecov-action
- name: Codecov
uses: codecov/codecov-action@v4
# Commit built assets if necessary
- name: Commit built assets
if: github.event_name == 'push' && github.ref == 'refs/heads/develop'
shell: 'script -q -e -c "bash --noprofile --norc -eo pipefail {0}"' # avoid docker-compose "the input device is not a TTY" -- https://github.com/actions/runner/issues/241#issuecomment-842566950
run: |
set -x
git config user.email "[email protected]"
git config user.name "Github Actions"
if [[ `git status docker-compose.yml docker-compose.override.yml --porcelain` ]] ; then
git add docker-compose.yml docker-compose.override.yml
git commit -m "Bump image version [skip ci]"
git push origin develop || exit 1
fi
if [[ `git status perma_web/static/bundles/ perma_web/webpack-stats.json --porcelain` ]] ; then
git add perma_web/static/bundles/ perma_web/webpack-stats.json
git commit -m "Add built JS [skip ci]"
git push origin develop || exit 1
fi
### push docker images to registry, from main branch, once tests pass ###
### (free disk space first) ###
- name: Free Disk Space (Ubuntu)
if: github.event_name == 'push' && github.ref == 'refs/heads/develop'
uses: jlumbroso/free-disk-space@main
with:
# this might remove tools that are actually needed,
# if set to "true" but frees about 6 GB
tool-cache: false
# all of these default to true, but feel free to set to
# "false" if necessary for your workflow
android: true
dotnet: true
haskell: true
large-packages: true
docker-images: false
swap-storage: true
- name: Push docker images
if: github.event_name == 'push' && github.ref == 'refs/heads/develop'
uses: harvard-lil/docker-compose-update-action@main
with:
registry: "registry.lil.tools"
registry-user: ${{ secrets.REPOSITORY_USER }}
registry-pass: ${{ secrets.REPOSITORY_TOKEN }}
bake-action: "push"