-
Notifications
You must be signed in to change notification settings - Fork 6
70 lines (59 loc) · 3.16 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
name: Tests
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-20.04
# don't run on pushes to forks
if: github.event_name == 'pull_request' || github.repository == 'harvard-lil/perma-payments'
steps:
- uses: actions/checkout@v2
### build docker images locally ###
- name: Rebuild docker images
id: rebuild
uses: harvard-lil/docker-compose-update-action@main
### run tests ###
- name: docker compose up
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 ps -a # show running containers
docker compose logs # show logs
- 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 test --ci
### codecov ###
# https://github.com/codecov/codecov-action
- name: Codecov
uses: codecov/codecov-action@v1
# Commit image version change if necessary, then deploy via Salt reactor
- name: Deploy
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
env:
DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }}
DEPLOY_URL: ${{ secrets.DEPLOY_URL }}
DEPLOY_HEADER: ${{ secrets.DEPLOY_HEADER }}
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
export DEPLOY_CONTENT='{"GITHUB_RUN_NUMBER":"'$GITHUB_RUN_NUMBER'","GITHUB_SHA":"'$GITHUB_SHA'","GITHUB_REF":"'$GITHUB_REF'","GITHUB_REPOSITORY":"'$GITHUB_REPOSITORY'","GITHUB_ACTOR":"'$GITHUB_ACTOR'"}' ;
export DEPLOY_SIG="sha1=`echo -n "$DEPLOY_CONTENT" | openssl sha1 -hmac $DEPLOY_KEY | sed 's/^.* //'`" ;
curl -X POST "$DEPLOY_URL" --data "$DEPLOY_CONTENT" -H "Content-Type: application/json" -H "$DEPLOY_HEADER: $DEPLOY_SIG"
- 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"