Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 0 additions & 30 deletions .github/workflows/build.yml

This file was deleted.

34 changes: 0 additions & 34 deletions .github/workflows/build_dev.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ permissions:
on:
workflow_call:
inputs:
build-tag:
required: true
type: string
cache-from:
required: true
type: string
Expand All @@ -30,10 +33,10 @@ jobs:
file: dev/Dockerfile
platforms: linux/amd64
outputs: type=docker,dest=/tmp/myimage.tar
tags: ghcr.io/${{ github.repository }}:${{ github.ref_name }}
tags: ghcr.io/${{ github.repository }}:${{ inputs.build-tag }}
cache-from: ${{ inputs.cache-from }}
# specific "cache-to" here as otherwise it would override the latest multi-platform cache with this amd64-only one
cache-to: type=registry,ref=ghcr.io/${{ github.repository }}-builder-cache:${{ github.ref_name }}-amd64,mode=max
cache-to: type=registry,ref=ghcr.io/${{ github.repository }}-builder-cache:${{ inputs.build-tag }}-amd64,mode=max

- name: Upload artifact
uses: actions/upload-artifact@v3
Expand Down
49 changes: 35 additions & 14 deletions .github/workflows/build_pr.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,45 @@
name: ci pr
name: pull request ci

on:
push:
branches-ignore:
pull_request:
branches:
- main
- dev
- dev-*


jobs:
test_image:
uses: ./.github/workflows/lib_test_image.yml
tag:
name: get latest tag
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.doit.outputs.new }}
steps:
- uses: actions/checkout@v3
- id: doit
env:
FALLBACK_VERSION: "1.0.0"
run: |
latest=$(git for-each-ref --sort=-creatordate --count 1 --format="%(refname:short)" "refs/tags/v*" | cut -b 2-)
if [[ $latest -eq "" ]]; then
latest=$FALLBACK_VERSION
echo "No tag found, using fallback: $latest"
fi
new=$(echo $latest | awk -F. '{OFS="."; $NF+=1; print $0}')
echo "new=$new" >> $GITHUB_OUTPUT

build_img:
needs: tag
uses: ./.github/workflows/build_image.yml
with:
build-tag: ${{ needs.tag.outputs.tag }}-${{ github.run_id }}-dev
cache-from: |
type=registry,ref=ghcr.io/${{ github.repository }}-builder-cache:latest
type=registry,ref=ghcr.io/${{ github.repository }}-builder-cache:${{ github.ref_name }}
type=registry,ref=ghcr.io/${{ github.repository }}-builder-cache:${{ needs.tag.outputs.tag }}-${{ github.run_id }}-dev

tests:
needs: test_image
uses: ./.github/workflows/lib_tests.yml

needs: [tag, build_img]
uses: ./.github/workflows/run_tests.yml
with:
build-tag: ${{ needs.tag.outputs.tag }}-${{ github.run_id }}-dev

testscleanup:
needs: tests
uses: ./.github/workflows/lib_test_cleanup.yml
needs: tests
uses: ./.github/workflows/test_cleanup.yml
39 changes: 0 additions & 39 deletions .github/workflows/lib_push_image.yml

This file was deleted.

62 changes: 62 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: release tag

on:
release:
types:
- [created]

jobs:
tag:
runs-on: ubuntu-latest
name: get latest tag
outputs:
tag: ${{ steps.doit.outputs.new }}
steps:
- id: doit
$run: echo "new=$(echo ${{ github.ref_name }} | cut -b 2-)" >> $GITHUB_OUTPUT

build_img:
needs: get_tag
uses: ./.github/workflows/build_image.yml
with:
build-tag: ${{ needs.tag.outputs.tag }}
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}-builder-cache:latest

tests:
needs: [tag, test_image]
uses: ./.github/workflows/run_tests.yml
with:
build-tag: ${{ needs.tag.outputs.tag }}

testscleanup:
needs: [tag, tests]
uses: ./.github/workflows/test_cleanup.yml
with:
build-tag: ${{ needs.tag.outputs.tag }}

push:
needs: [tag, tests]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GHCR
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v3
with:
file: dev/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ghcr.io/${{ github.repository }}:${{ github.run_number }},ghcr.io/${{ github.repository }}:${{ needs.tag.outputs.tag }}
cache-from: |
type=registry,ref=ghcr.io/${{ github.repository }}-builder-cache:latest
type=registry,ref=ghcr.io/${{ github.repository }}-builder-cache:${{ needs.tag.outputs.tag }}-amd64
cache-to: type=registry,ref=ghcr.io/${{ github.repository }}-builder-cache:latest,mode=max
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ name: tests

on:
workflow_call:
inputs:
build-tag:
required: true
type: string

jobs:
style:
Expand Down Expand Up @@ -33,15 +37,14 @@ jobs:

services:
mysql:
image: mysql:5
env:
MYSQL_ROOT_PASSWORD: root
image: mysql:8
ports:
- 8877:3306
# needed because the container does not provide a healthcheck
options: --health-cmd "mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries=5
options: --health-cmd "mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries=5 -e MYSQL_ROOT_PASSWORD=root --entrypoint sh mysql -c "exec docker-entrypoint.sh mysqld --default-authentication-plugin=mysql_native_password"

postgres:
image: postgres:10
image: postgres:15
env:
POSTGRES_USER: root
POSTGRES_PASSWORD: root
Expand All @@ -59,15 +62,14 @@ jobs:
path: /tmp

- name: Load Docker images from previous workflows
run: |
docker load --input /tmp/myimage.tar
run: docker load --input /tmp/myimage.tar

- name: run tests
run: |
docker run --network host \
-e SURF_DATABASE_URL=${{ matrix.database.url }} \
-v $(pwd)/cov/:/report \
ghcr.io/${{ github.repository }}:${{ github.ref_name }} \
ghcr.io/${{ github.repository }}:${{ inputs.build-tag }} \
sh -c 'pip install -r requirements_test.txt && pytest -n4 --cov --cov-report=xml:/report/coverage.xml'

- uses: codecov/codecov-action@v3
Expand Down