-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
118 additions
and
118 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,16 +24,13 @@ defaults: | |
|
||
|
||
jobs: | ||
setup: | ||
# if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name | ||
changes: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
timeout-minutes: 1 | ||
defaults: | ||
run: | ||
shell: bash | ||
outputs: | ||
checksum: ${{ steps.checksum.outputs.checksum }} | ||
version: ${{ steps.meta.outputs.version }} | ||
run_tests: ${{ steps.changes.outputs.run_tests }} | ||
steps: | ||
- name: Checkout code | ||
|
@@ -45,6 +42,21 @@ jobs: | |
base: ${{ github.ref }} | ||
token: ${{ github.token }} | ||
filters: .github/file-filters.yml | ||
setup: | ||
needs: [changes] | ||
if: needs.changes.outputs.run_tests == 'true' || contains(github.event.head_commit.message, 'ci:test') | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
defaults: | ||
run: | ||
shell: bash | ||
outputs: | ||
checksum: ${{ steps.checksum.outputs.checksum }} | ||
version: ${{ steps.meta.outputs.version }} | ||
image_name: ${{steps.image_name.outputs.name}} | ||
steps: | ||
- name: Checkout code | ||
uses: actions/[email protected] | ||
- name: Install regctl | ||
uses: regclient/actions/regctl-installer@main | ||
- name: Prepare Build Args | ||
|
@@ -61,50 +73,42 @@ jobs: | |
prefix=test- | ||
env: | ||
DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index | ||
- name: "Image Name" | ||
id: image_name | ||
run: echo "name=${{ vars.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }}" >> $GITHUB_OUTPUT | ||
- name: "Check Image" | ||
id: image_status | ||
shell: bash | ||
run: | | ||
image_checksum=$(regctl image inspect \ | ||
-p linux/amd64 \ | ||
--format '{{index .Config.Labels "checksum"}}' \ | ||
${{ vars.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }}) | ||
code_checksum="${{ steps.build_args.outputs.checksum }}" | ||
image_checksum=$(regctl image inspect -p linux/amd64 \ | ||
--format '{{index .Config.Labels "checksum"}}' \ | ||
${{ steps.image_name.outputs.name }} ) | ||
code_checksum="${{ steps.build_args.outputs.CHECKSUM }}" | ||
if [[ -z "$image_checksum" ]]; then | ||
echo "::warning:: No image checksum found" | ||
echo "::warning::🤔 No image checksum found" | ||
echo "updated=false" >> $GITHUB_OUTPUT | ||
elif [[ $image_checksum == $code_checksum ]]; then | ||
echo "::notice:: Image is updated" | ||
echo "::notice::😀 Image is updated" | ||
echo "updated=true" >> $GITHUB_OUTPUT | ||
else | ||
echo "::warning:: Checksum: found '${image_checksum}' expected '${code_checksum}'" | ||
echo "::warning::🤬 Checksum: found '${image_checksum}' expected '${code_checksum}'" | ||
echo "updated=false" >> $GITHUB_OUTPUT | ||
fi | ||
- name: "---" | ||
shell: bash | ||
run: | | ||
echo "Image Status" | ||
echo ${{ steps.image_status.updated }} | ||
echo "========== Labels" | ||
echo "${{ steps.meta.outputs.labels }}" | ||
echo "========== annotations" | ||
echo "${{ steps.meta.outputs.annotations }}" | ||
echo "========== tags" | ||
echo "${{ steps.meta.outputs.tags }}" | ||
echo "========== regctl manifest" | ||
regctl manifest get ${{ vars.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }} -p linux/amd64 | ||
echo "========== regctl image inspect" | ||
regctl image inspect -p linux/amd64 ${{ vars.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }} | jq '.config.Labels' | ||
- name: DockerHub login | ||
uses: docker/[email protected] | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
build: | ||
name: Build Test Image | ||
needs: [setup] | ||
runs-on: ubuntu-latest | ||
if: needs.setup.outputs.updated != 'true' | ||
steps: | ||
- name: Set up Docker Buildx | ||
uses: docker/[email protected] | ||
if: ${{ steps.image_status.updated != 'true' }} | ||
with: | ||
platforms: linux/amd64 | ||
driver: docker-container | ||
|
@@ -113,30 +117,27 @@ jobs: | |
network=host | ||
- name: Build and push | ||
id: build_push | ||
if: ${{ steps.image_status.updated != 'true' }} | ||
shell: bash | ||
run: echo "BUILDING...." | ||
# uses: docker/build-push-action@v6 | ||
# with: | ||
# context: . | ||
# tags: ${{ steps.meta.outputs.tags }} | ||
# labels: "${{ steps.meta.outputs.labels }}\na=1\nb=2" | ||
# annotations: "${{ steps.meta.outputs.annotations }}\nchecksum=${{ steps.build_args.outputs.checksum }}\ncommit=${{ steps.build_args.outputs.source_commit }}" | ||
# target: 'python_dev_deps' | ||
# file: ./docker/Dockerfile | ||
# platforms: linux/amd64 | ||
# push: true | ||
# sbom: true | ||
# provenance: true | ||
# cache-from: type=registry,ref=${{ vars.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }}-cache | ||
# cache-to: type=registry,ref=${{ vars.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }}-cache,mode=max,image-manifest=true | ||
# build-args: | | ||
# BUILD_DATE=${{ steps.build_args.outputs.build_date }} | ||
# CHECKSUM=${{ steps.build_args.outputs.checksum }} | ||
# VERSION=${{ steps.meta.outputs.version }} | ||
# SOURCE_COMMIT=${{ steps.build_args.outputs.source_commit }} | ||
# GITHUB_SERVER_URL=${{ github.server_url }} | ||
# GITHUB_REPOSITORY=${{ github.repository }} | ||
uses: docker/build-push-action@v6 | ||
with: | ||
context: . | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: "${{ steps.meta.outputs.labels }}\na=1\nb=2" | ||
annotations: "${{ steps.meta.outputs.annotations }}\nchecksum=${{ steps.build_args.outputs.checksum }}\ncommit=${{ steps.build_args.outputs.source_commit }}" | ||
target: 'python_dev_deps' | ||
file: ./docker/Dockerfile | ||
platforms: linux/amd64 | ||
push: true | ||
sbom: true | ||
provenance: true | ||
cache-from: type=registry,ref=${{ vars.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }}-cache | ||
cache-to: type=registry,ref=${{ vars.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }}-cache,mode=max,image-manifest=true | ||
build-args: | | ||
BUILD_DATE=${{ steps.build_args.outputs.build_date }} | ||
CHECKSUM=${{ steps.build_args.outputs.checksum }} | ||
VERSION=${{ steps.meta.outputs.version }} | ||
SOURCE_COMMIT=${{ steps.build_args.outputs.source_commit }} | ||
GITHUB_SERVER_URL=${{ github.server_url }} | ||
GITHUB_REPOSITORY=${{ github.repository }} | ||
# - uses: int128/docker-manifest-create-action@v2 | ||
# with: | ||
|
@@ -151,69 +152,68 @@ jobs: | |
# provenance: true | ||
# sbom: true | ||
# load: true# | ||
# test: | ||
# name: Run Test Suite | ||
# needs: [setup,build] | ||
# if: needs.setup.outputs.run_tests == 'true' || contains(github.event.head_commit.message, 'ci:test') | ||
## && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name) | ||
# runs-on: ubuntu-latest | ||
# services: | ||
# redis: | ||
# image: redis | ||
# db: | ||
# image: postgres:14 | ||
# env: | ||
# POSTGRES_DATABASE: dedupe | ||
# POSTGRES_PASSWORD: postgres | ||
# POSTGRES_USERNAME: postgres | ||
# ports: | ||
# - 5432:5432 | ||
# options: >- | ||
# --health-cmd pg_isready | ||
# --health-interval 10s | ||
# --health-timeout 5s | ||
# --health-retries 5 | ||
# env: | ||
# DOCKER_DEFAULT_PLATFORM: linux/amd64 | ||
# steps: | ||
# - name: Checkout code | ||
# uses: actions/checkout@v4 | ||
# - name: Image meta | ||
# id: info | ||
# uses: ./.github/actions/image_meta | ||
# with: | ||
# checksum: "-" | ||
# image: ${{needs.build.outputs.image}} | ||
# username: ${{ inputs.username }} | ||
# password: ${{ inputs.password }} | ||
# debug: true | ||
# - name: Dump 'Build' outputs | ||
# run: echo "${{ toJSON(needs.build.outputs) }}" | ||
# - name: Dump 'Setup' outputs | ||
# run: echo "${{ toJSON(needs.setup.outputs) }}" | ||
# - name: Dump Image meta | ||
# run: echo "${{ toJSON(steps.info.outputs) }}" | ||
# - name: Run tests | ||
# run: | | ||
# docker run --rm \ | ||
# -e DATABASE_URL=postgres://postgres:postgres@localhost:5432/dedupe \ | ||
# -e SECRET_KEY=secret_key \ | ||
# -e CACHE_URL=redis://redis:6379/0 \ | ||
# -e CELERY_BROKER_URL=redis://redis:6379/0 \ | ||
# --network host \ | ||
# -v $PWD:/code/app \ | ||
# -w /code/app \ | ||
# -t ${{needs.build.outputs.image}} \ | ||
# pytest tests -v --create-db -v --maxfail=10 | ||
# - name: Upload coverage to Codecov | ||
# uses: codecov/codecov-action@v4 | ||
# with: | ||
# env_vars: OS,PYTHON | ||
# fail_ci_if_error: true | ||
# files: coverage.xml | ||
# token: ${{ secrets.CODECOV_TOKEN }} | ||
# verbose: false | ||
# name: codecov-${{env.GITHUB_REF_NAME}} | ||
test: | ||
name: Run Test Suite | ||
needs: [changes,setup,build] | ||
if: needs.changes.outputs.run_tests == 'true' || contains(github.event.head_commit.message, 'ci:test') | ||
runs-on: ubuntu-latest | ||
services: | ||
redis: | ||
image: redis | ||
db: | ||
image: postgres:14 | ||
env: | ||
POSTGRES_DATABASE: dedupe | ||
POSTGRES_PASSWORD: postgres | ||
POSTGRES_USERNAME: postgres | ||
ports: | ||
- 5432:5432 | ||
options: >- | ||
--health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
env: | ||
DOCKER_DEFAULT_PLATFORM: linux/amd64 | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
- name: Image meta | ||
id: info | ||
uses: ./.github/actions/image_meta | ||
with: | ||
checksum: "-" | ||
image: ${{needs.build.outputs.image}} | ||
username: ${{ inputs.username }} | ||
password: ${{ inputs.password }} | ||
debug: true | ||
- name: Dump 'Build' outputs | ||
run: echo "${{ toJSON(needs.build.outputs) }}" | ||
- name: Dump 'Setup' outputs | ||
run: echo "${{ toJSON(needs.setup.outputs) }}" | ||
- name: Dump Image meta | ||
run: echo "${{ toJSON(steps.info.outputs) }}" | ||
- name: Run tests | ||
run: | | ||
docker run --rm \ | ||
-e DATABASE_URL=postgres://postgres:postgres@localhost:5432/dedupe \ | ||
-e SECRET_KEY=secret_key \ | ||
-e CACHE_URL=redis://redis:6379/0 \ | ||
-e CELERY_BROKER_URL=redis://redis:6379/0 \ | ||
--network host \ | ||
-v $PWD:/code/app \ | ||
-w /code/app \ | ||
-t ${{needs.build.outputs.image}} \ | ||
pytest tests -v --create-db -v --maxfail=10 | ||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v4 | ||
with: | ||
env_vars: OS,PYTHON | ||
fail_ci_if_error: true | ||
files: coverage.xml | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
verbose: false | ||
name: codecov-${{env.GITHUB_REF_NAME}} | ||
# | ||
# | ||
# trivy: | ||
|