diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index c15fb3ac..3d3281a1 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -12,6 +12,7 @@ env: # github.repository as / #IMAGE_NAME: ${{ github.repository }} IMAGE_NAME: theshellland/automonisaur + DOCKER_IMAGE: automonisaur PKG: automon PYPI: automonisaur @@ -27,7 +28,21 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - run: docker build . --tag ${{ env.IMAGE_NAME }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - name: Build and push + uses: docker/build-push-action@v2 + with: + context: . + file: ./Dockerfile + tags: ${{ env.DOCKER_IMAGE }} + outputs: type=docker,dest=/tmp/${{ env.DOCKER_IMAGE }}.tar + - name: Upload artifact + uses: actions/upload-artifact@v2 + with: + name: ${{ env.DOCKER_IMAGE }}.tar + path: /tmp/${{ env.DOCKER_IMAGE }}.tar test: @@ -35,8 +50,27 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - run: docker build . --tag ${{ env.IMAGE_NAME }} - - run: docker run ${{ env.IMAGE_NAME }} test + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - name: Download artifact + uses: actions/download-artifact@v2 + with: + name: ${{ env.DOCKER_IMAGE }} + path: /tmp + - name: Load Docker image + run: | + docker load --input /tmp/${{ env.DOCKER_IMAGE }}.tar + - name: Run tests + run: | + docker run \ + -e PKG="${{ secrets.PKG }}" \ + -e PYPI="${{ secrets.PYPI }}" \ + -e TWINE_REPOSITORY="${{ secrets.TWINE_REPOSITORY }}" \ + -e TWINE_REPOSITORY_URL="${{ secrets.TWINE_REPOSITORY_URL }}" \ + -e TWINE_USERNAME="${{ secrets.TWINE_USERNAME }}" \ + -e TWINE_PASSWORD="${{ secrets.TWINE_PASSWORD }}" \ + ${{ env.DOCKER_IMAGE }} test publish-coverage: @@ -45,29 +79,40 @@ jobs: # upload coverage report steps: - uses: actions/checkout@v2 - - run: docker build . --tag ${{ env.IMAGE_NAME }} - - name: Codecov - uses: codecov/codecov-action@v1.0.12 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - name: Download artifact + uses: actions/download-artifact@v2 with: - # User defined upload name. Visible in Codecov UI - name: # optional - # Repository upload token - get it from codecov.io. Required only for private repositories - token: # optional - # Path to coverage file to upload - file: # optional - # Comma-separated list of files to upload - files: # optional - # Directory to search for coverage reports. - directory: # optional - # Flag upload to group coverage metrics (e.g. unittests | integration | ui,chrome) - flags: # optional - # Write upload file to path before uploading - path_to_write_report: # optional - # Environment variables to tag the upload with (e.g. PYTHON | OS,PYTHON) - env_vars: # optional - # Specify whether or not CI build should fail if Codecov runs into an error during upload - fail_ci_if_error: # optional + name: ${{ env.DOCKER_IMAGE }} + path: /tmp + - name: Load Docker image + run: docker load --input /tmp/${{ env.DOCKER_IMAGE }}.tar + - name: Upload coverage + run: docker run ${{ env.DOCKER_IMAGE }} test html + +# - name: Codecov +# uses: codecov/codecov-action@v1.0.12 +# with: +# # User defined upload name. Visible in Codecov UI +# name: # optional +# # Repository upload token - get it from codecov.io. Required only for private repositories +# token: # optional +# # Path to coverage file to upload +# file: # optional +# # Comma-separated list of files to upload +# files: # optional +# # Directory to search for coverage reports. +# directory: # optional +# # Flag upload to group coverage metrics (e.g. unittests | integration | ui,chrome) +# flags: # optional +# # Write upload file to path before uploading +# path_to_write_report: # optional +# # Environment variables to tag the upload with (e.g. PYTHON | OS,PYTHON) +# env_vars: # optional +# # Specify whether or not CI build should fail if Codecov runs into an error during upload +# fail_ci_if_error: # optional publish-pypi: @@ -75,7 +120,20 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - run: docker run ${{ env.IMAGE_NAME }} upload + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - name: Download artifact + uses: actions/download-artifact@v2 + with: + name: ${{ env.DOCKER_IMAGE }} + path: /tmp + - name: Load Docker image + run: | + docker load --input /tmp/${{ env.DOCKER_IMAGE }}.tar + + - name: Upload to pypi + run: docker run ${{ env.DOCKER_IMAGE }} upload publish-docker: diff --git a/entry.sh b/entry.sh index 01ac0656..ba9f6a25 100755 --- a/entry.sh +++ b/entry.sh @@ -2,7 +2,7 @@ # entrypoint -cd $(dirname $0) && set -e +cd $(dirname $0) && set -ex if [ "$1" == "test" ]; then exec /bin/bash unittests.sh "$2" diff --git a/unittests.sh b/unittests.sh index 6bea012f..7dd79af9 100755 --- a/unittests.sh +++ b/unittests.sh @@ -1,6 +1,6 @@ #!/bin/bash -cd $(dirname $0) && set -ex +cd $(dirname $0) && set -e # TODO: set pre-commit hook