Skip to content

Merge pull request #175 from bensteinberg/try-bookworm #40

Merge pull request #175 from bensteinberg/try-bookworm

Merge pull request #175 from bensteinberg/try-bookworm #40

Workflow file for this run

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"