Minor debugging based on unit tests #719
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: Continuous Integration | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
jobs: | |
build: | |
name: Run all tests | |
runs-on: ubuntu-latest | |
env: | |
POSTGRES_HOST: "postgres" | |
POSTGRES_PORT: "5432" | |
POSTGRES_DB: "testing" | |
POSTGRES_USER: "admin" | |
POSTGRES_PASSWORD: "12345" | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v2 | |
- name: Setup test environment | |
run: | | |
sudo mkdir /config | |
sudo touch /config/api.env | |
docker network create api | |
docker run -d --network=api --name=$POSTGRES_HOST -p $POSTGRES_PORT:5432 \ | |
-e POSTGRES_DB=$POSTGRES_DB \ | |
-e POSTGRES_USER=$POSTGRES_USER \ | |
-e POSTGRES_PASSWORD=$POSTGRES_PASSWORD \ | |
postgres:15.2 | |
- name: Build project | |
# Use docker-compose instead of docker compose because GitHub uses Ubuntu for testing. | |
run: | | |
docker-compose -f ops/build.yml build | |
- name: Run shared code tests | |
run: docker run --rm -t shared_build npm test | |
- name: Run frontend tests | |
run: docker run --rm -t -e CI=true frontend_build npm test | |
- name: Run api tests | |
run: | | |
touch lastSessionData && chmod 0777 lastSessionData | |
docker run --rm -t --network=api \ | |
-e POSTGRES_DB=$POSTGRES_DB \ | |
-e POSTGRES_ADMIN_USER=$POSTGRES_USER \ | |
-e POSTGRES_ADMIN_PASSWORD=$POSTGRES_PASSWORD \ | |
-e POSTGRES_APP_USER=$POSTGRES_USER \ | |
-e POSTGRES_APP_PASSWORD=$POSTGRES_PASSWORD \ | |
-e POSTGRES_HOST=$POSTGRES_HOST \ | |
-e POSTGRES_PORT=$POSTGRES_PORT \ | |
-v $(pwd)/lastSessionData:/app/lastSessionData \ | |
stepwisecom/api npm test | |
- name: Publish images (only on master branch) | |
if: github.ref == 'refs/heads/master' | |
env: | |
DOCKER_REGISTRY_KEY: ${{ secrets.DOCKER_REGISTRY_KEY }} | |
run: | | |
docker login --username stepwisecom --password $DOCKER_REGISTRY_KEY | |
docker image ls -f reference="stepwisecom/*" --format "{{.Repository}}" \ | |
| xargs -n 1 docker push |