Improve firm ("other org") sign-up workflow (#3595) #1879
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |