Skip to content

Build

Build #359

Workflow file for this run

name: Build
on:
pull_request:
merge_group:
push:
branches:
- develop
tags:
- '*'
jobs:
Build:
name: Build and Test on ${{ matrix.python }} and ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ['macos-latest', 'ubuntu-latest']
python: ['3.9', '3.10', '3.11']
steps:
- uses: actions/checkout@v5
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python }}
- name: Install dependencies
id: install-deps
run: |
pip3 install -r requirements.txt
pip3 install -r test/requirements.txt
- name: Run Unit tests
id: run-unit-tests
run: |
test/.bin/unit-tests.sh
- name: Run End2End tests
id: run-end2end-tests
run: |
test/.bin/e2e-tests.sh
Container:
name: Build Container Image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Write version vars
id: version-vars
run: |
BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"`
BRANCH=${GITHUB_REF_NAME#v}
APP_VERSION=$(cat config.json | jq -r ".version")
echo Version: $APP_VERSION
echo "VERSION=$APP_VERSION" >> $GITHUB_ENV
echo "APP_VERSION=$APP_VERSION" >> $GITHUB_ENV
echo "BUILD_DATE=$BUILD_DATE" >> $GITHUB_ENV
- name: Build Container Image
id: build-image
uses: docker/build-push-action@v6
with:
push: false
tags: |
cloudtooling/data-anonymizer:next
cloudtooling/data-anonymizer:${{github.run_id }}
cloudtooling/data-anonymizer:${{env.APP_VERSION}}_rc
build-args: |
BUILD_DATE=${{env.BUILD_DATE}}
APP_VERSION=${{env.APP_VERSION}}
- name: Run tests in container
id: run-tests
run: |
docker run -v $(pwd):/build --entrypoint "/app/test/.bin/e2e-tests.sh" cloudtooling/data-anonymizer:${{github.run_id }}
- name: Log in to GitHub container registry
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKER_HUB_USER}}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
if: github.ref == 'refs/heads/develop'
- name: Deploy Container Image
id: push-to-dockerhub-release
run: |
docker push cloudtooling/data-anonymizer:next
docker push cloudtooling/data-anonymizer:${{env.APP_VERSION}}_rc
if: github.ref == 'refs/heads/develop'
Build-results:
name: Build results
if: ${{ always() }}
runs-on: ubuntu-latest
needs:
- Build
- Container
steps:
- run: exit 1
# see https://stackoverflow.com/a/67532120/4907315
if: >-
${{
contains(needs.*.result, 'failure')
|| contains(needs.*.result, 'cancelled')
|| contains(needs.*.result, 'skipped')
}}