From e8cf414c9784474d28bcb3d45aa3a7646ea2b794 Mon Sep 17 00:00:00 2001 From: Nicholas-Schaub Date: Fri, 26 Jan 2024 15:29:12 -0500 Subject: [PATCH] Update tests.yml (#506) --- .github/workflows/tests.yml | 75 ++++++++++++++++++++++++++++++++----- 1 file changed, 66 insertions(+), 9 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1d505cf7c..25acc72a5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -6,6 +6,24 @@ on: - main - master - dev + push: + branches-ignore: + - main + - master + - dev + # workflow_call: + # secrets: + # DOCKER_USERNAME: + # description: 'Docker Hub username' + # required: true + # DOCKER_TOKEN: + # description: 'Docker Hub password' + # required: true + # description: 'Docker Hub username' + # required: true + # DOCKER_TOKEN: + # description: 'Docker Hub password' + # required: true permissions: contents: read @@ -19,13 +37,14 @@ jobs: name: Test "${{ matrix.package_name }}" needs: package-filter strategy: + fail-fast: false matrix: ${{fromJson(needs.package-filter.outputs.matrix)}} runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: '3.9' - name: Install Poetry @@ -50,13 +69,51 @@ jobs: poetry install poetry run pytest -v + # docker: + # name: Build Docker images + # needs: [package-filter, tests] + # uses: ./.github/workflows/docker.yml + # with: + # matrix: ${{ needs.package-filter.outputs.matrix }} + # push: true + # secrets: + # DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + # DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }} + docker: - name: Build Docker images + name: Docker "${{ matrix.package_name }}" needs: [package-filter, tests] - uses: ./.github/workflows/docker.yml - with: - matrix: ${{ needs.package-filter.outputs.matrix }} - push: false - secrets: - DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} - DOCKER_PASSWORD: ${{ secrets.DOCKER_TOKEN }} + strategy: + fail-fast: false + matrix: ${{fromJson(needs.package-filter.outputs.matrix)}} + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Get | Docker Tag + id: docker_tag + run: | + package_dir="${{ matrix.package_dir }}" + version=$(cat ${package_dir}/VERSION) + tag=polusai/${{ matrix.package_name }}:${version} + echo "tag=${tag}" >> $GITHUB_OUTPUT + - name: Setup | Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Login | DockerHub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_TOKEN }} + - name: Check | Image exists + run: | + tag=${{ steps.docker_tag.outputs.tag }} + docker pull ${tag} > /dev/null \ + && $(echo "::error::${tag} already exists on DockerHub" && exit 1) \ + || echo "success" + - name: Publish | Docker Image + uses: docker/build-push-action@v5 + with: + context: "{{defaultContext}}:${{ matrix.package_dir }}" + platforms: linux/amd64,linux/arm64 + push: false + tags: ${{ steps.docker_tag.outputs.tag }}