Replace no-cover pragmas with mocks. #134
Workflow file for this run
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: Container image | |
on: | |
push: | |
paths-ignore: | |
- 'ci/**' | |
- 'README.md' | |
schedule: | |
- cron: '40 08 * * 1' # Run every week to get updated dependencies. | |
pull_request: | |
types: [opened, reopened, synchronize] | |
workflow_dispatch: | |
jobs: | |
build: | |
name: Build image | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Docker build | |
run: docker build -t mreg . | |
- name: Save image | |
run: docker save mreg | gzip > mreg.tgz | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: mreg | |
path: mreg.tgz | |
test: | |
name: Unit tests | |
needs: build | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres:latest | |
env: | |
POSTGRES_USER: mreg | |
POSTGRES_PASSWORD: mreg | |
# Set health checks to wait until postgres has started | |
options: >- | |
--health-cmd "pg_isready --username=mreg" | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
# Map the containerized port to localhost. | |
- 5432:5432 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Download artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: mreg | |
- name: Load image | |
run: docker load --input mreg.tgz | |
- name: Run tests | |
run: | | |
docker run --rm -t --network host --entrypoint /app/entrypoint-test.sh \ | |
-e MREG_DB_HOST=localhost -e MREG_DB_PASSWORD=mreg -e MREG_DB_USER=mreg \ | |
mreg | |
mreg-cli: | |
name: Test with mreg-cli | |
needs: test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: mreg | |
- name: Load container image | |
run: docker load --input mreg.tgz | |
- name: Tag container image | |
# There's a docker-compose.yml file in the mreg-cli repo that wants the image from ghcr.io, | |
# but we want to use the newly built custom image | |
run: docker tag mreg ghcr.io/unioslo/mreg:latest | |
- name: Setup Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.11 | |
- name: Install mreg-cli | |
run: | | |
wget -nd https://github.com/unioslo/mreg-cli/archive/refs/heads/master.zip | |
unzip master.zip | |
cd mreg-cli-master | |
pip install -r requirements.txt | |
pip install -e . | |
- name: Run the tests | |
run: mreg-cli-master/ci/run_testsuite_and_record.sh | |
publish: | |
name: Publish | |
# only publish the image if this event was triggered on the master branch, and not by a pull request | |
if: ${{ github.ref == 'refs/heads/master' && github.event_name != 'pull_request' }} | |
needs: mreg-cli | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write | |
contents: read | |
steps: | |
- name: Download artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: mreg | |
- name: Load image | |
run: docker load --input mreg.tgz | |
- name: Log in to registry | |
run: > | |
echo "${{ secrets.GITHUB_TOKEN }}" | |
| docker login ghcr.io -u ${{ github.actor }} --password-stdin | |
- name: Push image | |
run: | | |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/mreg | |
TAG_NAME=latest | |
docker tag mreg:latest $IMAGE_ID:$TAG_NAME | |
docker push $IMAGE_ID:$TAG_NAME |