Add CI running integration tests and creating docker image #94
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: CI build | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '0 10 * * *' # every day at 10am | |
push: | |
branches: | |
- master | |
tags: | |
- 'v*.*.*' | |
pull_request: | |
permissions: | |
contents: read | |
packages: write | |
jobs: | |
integration-tests: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/[email protected] | |
- name: Set up Docker Buildx | |
uses: docker/[email protected] | |
- name: Run compose | |
run: | | |
cd $GITHUB_WORKSPACE/compose | |
docker compose -f docker-compose-integration-tests.yml up -d | |
- name: Prepare python environment | |
run: | | |
cd $GITHUB_WORKSPACE | |
pip install -r requirements.txt | |
- name: Wait for Directory service | |
run: | | |
cd $GITHUB_WORKSPACE/tests/scripts | |
python wait_for_service.py | |
- name: Load test data for Directory | |
run: | | |
cd $GITHUB_WORKSPACE/tests/scripts | |
python load_directory_data.py | |
sleep 120 | |
- name: Run Integration tests | |
run: | | |
cd $GITHUB_WORKSPACE/tests/integration | |
pytest integration_tests.py | |
- name: Down compose | |
run: | | |
cd $GITHUB_WORKSPACE/compose | |
docker compose -f docker-compose-integration-tests.yml down | |
- name: Run service deploy tests | |
run: | | |
cd $GITHUB_WORKSPACE/tests/deployment | |
pytest standalone_service_test.py | |
build-docker-image: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/[email protected] | |
- name: Set up Docker Buildx | |
uses: docker/[email protected] | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5 | |
with: | |
images: | | |
ghcr.io/${{ github.repository_owner }}/directory-negotiator-sync | |
tags: | | |
type=ref,event=branch | |
type=raw,value=${{ github.head_ref }},event=pr | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }} | |
- name: Build and push | |
uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75 # v6 | |
with: | |
context: . | |
platforms: linux/amd64 | |
push: true | |
labels: ${{ steps.meta.outputs.labels }} | |
tags: ${{ steps.meta.outputs.tags }} | |
build-args: ARTIFACT_VERSION=${{ github.ref_name }} | |