Skip to content
This repository has been archived by the owner on Oct 16, 2024. It is now read-only.

Update to debian bookworm #855

Update to debian bookworm

Update to debian bookworm #855

Workflow file for this run

name: Tests
on: [push, pull_request]
defaults:
run:
working-directory: capstone
jobs:
test:
runs-on: ubuntu-20.04
# don't run on pushes to forks
if: github.event_name == 'pull_request' || github.repository == 'harvard-lil/capstone'
steps:
- uses: actions/checkout@v2
### build docker images locally ###
- name: Rebuild docker images
id: rebuild
uses: harvard-lil/docker-compose-update-action@main
with:
working-directory: capstone
### run tests ###
- name: docker-compose up
run: |
sudo sysctl -w vm.max_map_count=262144 # for elasticsearch's bootstrap check
# 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: 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-745902718
run: docker-compose exec web ./manage.py collectstatic --noinput # collect static files
- name: Run 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-745902718
run: |
set -x
docker-compose exec web pytest \
`# disabling these in case it helps with intermittent test timeouts:` \
`#-n 2 # run tests in parallel for speed` \
`#--junitxml=junit/pytest/test-results.xml # write junit test results so they can be displayed somewhere later?` \
--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@v1
with:
directory: capstone/
# Commit built assets if necessary
- name: Commit
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" -- see https://github.com/actions/runner/issues/241#issuecomment-745902718
run: |
set -x
git config user.email "[email protected]"
git config user.name "Github Actions"
docker-compose exec web yarn build
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 static/dist/ --porcelain` ]] ; then
git add static/dist/
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 ###
- name: Push docker images
if: github.event_name == 'push' && github.ref == 'refs/heads/develop'
uses: harvard-lil/docker-compose-update-action@main
with:
working-directory: capstone
registry: "registry.lil.tools"
registry-user: ${{ secrets.REPOSITORY_USER }}
registry-pass: ${{ secrets.REPOSITORY_TOKEN }}
bake-action: "push"
### deploy via Salt reactor ###
- name: Deploy
if: github.event_name == 'push' && github.ref == 'refs/heads/develop'
env:
DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }}
DEPLOY_URL: ${{ secrets.DEPLOY_URL }}
DEPLOY_HEADER: ${{ secrets.DEPLOY_HEADER }}
run: |
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"