Skip to content

Commit

Permalink
ci: push job need tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tristiisch committed Sep 30, 2024
1 parent b85c4e8 commit 88cce97
Showing 1 changed file with 77 additions and 77 deletions.
154 changes: 77 additions & 77 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ jobs:
- name: Prepare
run: |
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
echo "platform_pair=${platform//\//-}" >> $GITHUB_OUTPUT
id: prepare

- name: Checkout repository
uses: actions/checkout@v4
Expand Down Expand Up @@ -207,24 +208,94 @@ jobs:
PROJECT_VERSION=${{ needs.info.outputs.project_version }}
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true

- name: Export digest
- name: Export image digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
- name: Upload image digest as artifact
uses: actions/upload-artifact@v4
with:
name: digests-${{ env.PLATFORM_PAIR }}
name: digests-${{ steps.prepare.outputs.platform_pair }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1

docker_image_test_build:
name: "Build Tests"
needs: ["info", "docker_image_build"]
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Docker image Build
id: build
uses: docker/build-push-action@v6
with:
file: ./Dockerfile
target: tests
context: .
tags: pyramid:tests
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
PROJECT_VERSION=${{ needs.info.outputs.project_version }}-tests
push: false
outputs: type=docker

- name: Export tests image
run: docker save pyramid:tests -o "./pyramid-tests.tar"

- name: Upload tests image as artifact
uses: actions/upload-artifact@v4
with:
name: image-tests
path: ./pyramid-tests.tar
if-no-files-found: error
retention-days: 1

tests_in_docker:
name: "Tests"
needs: ["docker_image_test_build"]
runs-on: ubuntu-latest

steps:
- name: Download tests image
uses: actions/download-artifact@v4
with:
name: image-tests

- name: Load Docker image
run: docker load -i "./pyramid-tests.tar"

- name: Run unit tests
run: |
mkdir -p ./coverage && chmod 777 ./coverage
docker run --rm -v ./coverage:/app/coverage -e SPOTIFY__CLIENT_ID=${{ secrets.CONFIG_SPOTIFY_CLIENT_ID }} -e SPOTIFY__CLIENT_SECRET=${{ secrets.CONFIG_SPOTIFY_CLIENT_SECRET }} pyramid:tests
- name: Upload coverage reports to Codecov
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: tristiisch/PyRamid
files: ./coverage/cover/result

docker_image_push:
name: "Push"
runs-on: ubuntu-latest
needs: ["info", "docker_image_build"]
needs: ["info", "docker_image_build", "tests_in_docker"]
if: github.event_name == 'push'

steps:
Expand Down Expand Up @@ -259,7 +330,7 @@ jobs:
docker_image_push_private:
name: "Push Privates"
runs-on: ubuntu-latest
needs: ["info", "docker_image_build"]
needs: ["info", "docker_image_build", "tests_in_docker"]
if: github.event_name == 'push'

steps:
Expand Down Expand Up @@ -349,74 +420,3 @@ jobs:
--notes-file "./changelog.txt"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}


docker_image_test_build:
name: "Build Tests"
needs: ["info", "docker_image_build"]
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Docker image Build
id: build
uses: docker/build-push-action@v6
with:
file: ./Dockerfile
target: tests
context: .
tags: pyramid:tests
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
PROJECT_VERSION=${{ needs.info.outputs.project_version }}-tests
push: false
outputs: type=docker

- name: Export digest
run: docker save pyramid:tests -o "./pyramid-tests.tar"

- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-tests
path: ./pyramid-tests.tar
if-no-files-found: error
retention-days: 1

tests_in_docker:
name: "Tests"
needs: ["docker_image_test_build"]
runs-on: ubuntu-latest

steps:
- name: Download test digests
uses: actions/download-artifact@v4
with:
name: digests-tests

- name: Load Docker image
run: docker load -i "./pyramid-tests.tar"

- name: Run unit tests
run: |
mkdir -p ./coverage && chmod 777 ./coverage
docker run --rm -v ./coverage:/app/coverage -e SPOTIFY__CLIENT_ID=${{ secrets.CONFIG_SPOTIFY_CLIENT_ID }} -e SPOTIFY__CLIENT_SECRET=${{ secrets.CONFIG_SPOTIFY_CLIENT_SECRET }} pyramid:tests
- name: Upload coverage reports to Codecov
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: tristiisch/PyRamid
files: ./cover/result

0 comments on commit 88cce97

Please sign in to comment.