From 4085e0904bca7ed4903804c2a1827f973c7a85fc Mon Sep 17 00:00:00 2001 From: Uros Bajzelj Date: Thu, 1 Sep 2022 07:27:15 +0000 Subject: [PATCH 1/4] Update gha --- .github/workflows/ci.yml | 70 +++++++++++++++++++++++++++++++--------- 1 file changed, 54 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7503047..6edff72 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,8 +1,13 @@ --- name: "CI" on: # yamllint disable-line rule:truthy rule:comments - - "push" - - "pull_request" + push: + branches: + - "main" + - "develop" + tags: + - "v*" + pull_request: ~ env: IMAGE_NAME: "jdiff" @@ -41,8 +46,6 @@ jobs: uses: "networktocode/gh-action-setup-poetry-environment@v2" - name: "Linting: bandit" run: "poetry run invoke bandit" - needs: - - "black" pydocstyle: runs-on: "ubuntu-20.04" env: @@ -54,8 +57,6 @@ jobs: uses: "networktocode/gh-action-setup-poetry-environment@v2" - name: "Linting: pydocstyle" run: "poetry run invoke pydocstyle" - needs: - - "black" flake8: runs-on: "ubuntu-20.04" env: @@ -67,8 +68,6 @@ jobs: uses: "networktocode/gh-action-setup-poetry-environment@v2" - name: "Linting: flake8" run: "poetry run invoke flake8" - needs: - - "black" yamllint: runs-on: "ubuntu-20.04" env: @@ -80,8 +79,6 @@ jobs: uses: "networktocode/gh-action-setup-poetry-environment@v2" - name: "Linting: yamllint" run: "poetry run invoke yamllint" - needs: - - "black" build: strategy: fail-fast: true @@ -118,6 +115,13 @@ jobs: - "flake8" - "yamllint" pylint: + needs: + - "bandit" + - "pydocstyle" + - "flake8" + - "yamllint" + - "black" + - "mypy" runs-on: "ubuntu-20.04" strategy: fail-fast: true @@ -153,9 +157,9 @@ jobs: run: "docker image ls" - name: "Linting: Pylint" run: "poetry run invoke pylint" - needs: - - "build" pytest: + needs: + - "pylint" strategy: fail-fast: true matrix: @@ -191,9 +195,9 @@ jobs: run: "docker image ls" - name: "Run Tests" run: "poetry run invoke pytest" - needs: - - "pylint" publish_gh: + needs: + - "pytest" name: "Publish to GitHub" runs-on: "ubuntu-20.04" if: "startsWith(github.ref, 'refs/tags/v')" @@ -220,9 +224,9 @@ jobs: tag: "${{ github.ref }}" overwrite: true file_glob: true + publish_pypi: needs: - "pytest" - publish_pypi: name: "Push Package to PyPI" runs-on: "ubuntu-20.04" if: "startsWith(github.ref, 'refs/tags/v')" @@ -248,5 +252,39 @@ jobs: password: "${{ secrets.PYPI_API_TOKEN }}" # Using PyPi dev. repository_url: "https://test.pypi.org/legacy/" + slack-notify: needs: - - "pytest" + - "publish_gh" + - "publish_pypi" + name: "Send notification to the Slack" + runs-on: "ubuntu-20.04" + env: + SLACK_WEBHOOK_URL: "${{ secrets.SLACK_WEBHOOK_URL }}" + SLACK_MESSAGE: >- + *NOTIFICATION: NEW-RELEASE-PUBLISHED*\n + Repository: <${{ github.server_url }}/${{ github.repository }}|${{ github.repository }}>\n + Release: <${{ github.server_url }}/${{ github.repository }}/releases/tag/${{ github.ref_name }}|${{ github.ref_name }}>\n + Published by: <${{ github.server_url }}/${{ github.actor }}|${{ github.actor }}> + steps: + - name: "Send a notification to Slack" + # ENVs cannot be used directly in job.if. This is a workaround to check + # if SLACK_WEBHOOK_URL is present. + if: "${{ env.SLACK_WEBHOOK_URL != '' }}" + uses: "slackapi/slack-github-action@v1.17.0" + with: + payload: | + { + "text": "${{ env.SLACK_MESSAGE }}", + "blocks": [ + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "${{ env.SLACK_MESSAGE }}" + } + } + ] + } + env: + SLACK_WEBHOOK_URL: "${{ secrets.SLACK_WEBHOOK_URL }}" + SLACK_WEBHOOK_TYPE: "INCOMING_WEBHOOK" From 6db81ec14e4e8ecda3f6b8c307be839ae9391d5e Mon Sep 17 00:00:00 2001 From: Uros Bajzelj Date: Thu, 1 Sep 2022 07:29:21 +0000 Subject: [PATCH 2/4] Update gha --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6edff72..9e635e1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,6 +12,7 @@ on: # yamllint disable-line rule:truthy rule:comments env: IMAGE_NAME: "jdiff" + jobs: black: runs-on: "ubuntu-20.04" From d59d75ff8f93be9514244290b2a493eba4592221 Mon Sep 17 00:00:00 2001 From: Uros Bajzelj Date: Thu, 1 Sep 2022 07:30:10 +0000 Subject: [PATCH 3/4] Update gha --- .github/workflows/ci.yml | 36 ------------------------------------ 1 file changed, 36 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9e635e1..abda9fd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,6 @@ on: # yamllint disable-line rule:truthy rule:comments env: IMAGE_NAME: "jdiff" - jobs: black: runs-on: "ubuntu-20.04" @@ -80,41 +79,6 @@ jobs: uses: "networktocode/gh-action-setup-poetry-environment@v2" - name: "Linting: yamllint" run: "poetry run invoke yamllint" - build: - strategy: - fail-fast: true - matrix: - python-version: ["3.7", "3.8", "3.9", "3.10"] - runs-on: "ubuntu-20.04" - env: - PYTHON_VER: "${{ matrix.python-version }}" - steps: - - name: "Check out repository code" - uses: "actions/checkout@v2" - - name: "Setup environment" - uses: "networktocode/gh-action-setup-poetry-environment@v2" - - name: "Get image version" - run: "echo IMAGE_VER=`poetry version -s`-py${{ matrix.python-version }} >> $GITHUB_ENV" - - name: "Set up Docker Buildx" - id: "buildx" - uses: "docker/setup-buildx-action@v1" - - name: "Build" - uses: "docker/build-push-action@v2" - with: - builder: "${{ steps.buildx.outputs.name }}" - context: "./" - push: false - tags: "${{ env.IMAGE_NAME }}:${{ env.IMAGE_VER }}" - file: "./Dockerfile" - cache-from: "type=gha,scope=${{ env.IMAGE_NAME }}-${{ env.IMAGE_VER }}-py${{ matrix.python-version }}" - cache-to: "type=gha,scope=${{ env.IMAGE_NAME }}-${{ env.IMAGE_VER }}-py${{ matrix.python-version }}" - build-args: | - PYTHON_VER=${{ env.PYTHON_VER }} - needs: - - "bandit" - - "pydocstyle" - - "flake8" - - "yamllint" pylint: needs: - "bandit" From 91de3ec0e5418401cb49a21c027beb0203d2b1b9 Mon Sep 17 00:00:00 2001 From: Uros Bajzelj Date: Thu, 1 Sep 2022 07:36:38 +0000 Subject: [PATCH 4/4] Remove docker stuff --- .github/workflows/ci.yml | 43 ---------------------------------------- 1 file changed, 43 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index abda9fd..2e82d63 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,9 +9,6 @@ on: # yamllint disable-line rule:truthy rule:comments - "v*" pull_request: ~ -env: - IMAGE_NAME: "jdiff" - jobs: black: runs-on: "ubuntu-20.04" @@ -100,26 +97,6 @@ jobs: uses: "actions/checkout@v2" - name: "Setup environment" uses: "networktocode/gh-action-setup-poetry-environment@v2" - - name: "Get image version" - run: "echo IMAGE_VER=`poetry version -s`-py${{ matrix.python-version }} >> $GITHUB_ENV" - - name: "Set up Docker Buildx" - id: "buildx" - uses: "docker/setup-buildx-action@v1" - - name: "Load the image from cache" - uses: "docker/build-push-action@v2" - with: - builder: "${{ steps.buildx.outputs.name }}" - context: "./" - push: false - load: true - tags: "${{ env.IMAGE_NAME }}:${{ env.IMAGE_VER }}" - file: "./Dockerfile" - cache-from: "type=gha,scope=${{ env.IMAGE_NAME }}-${{ env.IMAGE_VER }}-py${{ matrix.python-version }}" - cache-to: "type=gha,scope=${{ env.IMAGE_NAME }}-${{ env.IMAGE_VER }}-py${{ matrix.python-version }}" - build-args: | - PYTHON_VER=${{ env.PYTHON_VER }} - - name: "Debug: Show docker images" - run: "docker image ls" - name: "Linting: Pylint" run: "poetry run invoke pylint" pytest: @@ -138,26 +115,6 @@ jobs: uses: "actions/checkout@v2" - name: "Setup environment" uses: "networktocode/gh-action-setup-poetry-environment@v2" - - name: "Get image version" - run: "echo IMAGE_VER=`poetry version -s`-py${{ matrix.python-version }} >> $GITHUB_ENV" - - name: "Set up Docker Buildx" - id: "buildx" - uses: "docker/setup-buildx-action@v1" - - name: "Load the image from cache" - uses: "docker/build-push-action@v2" - with: - builder: "${{ steps.buildx.outputs.name }}" - context: "./" - push: false - load: true - tags: "${{ env.IMAGE_NAME }}:${{ env.IMAGE_VER }}" - file: "./Dockerfile" - cache-from: "type=gha,scope=${{ env.IMAGE_NAME }}-${{ env.IMAGE_VER }}-py${{ matrix.python-version }}" - cache-to: "type=gha,scope=${{ env.IMAGE_NAME }}-${{ env.IMAGE_VER }}-py${{ matrix.python-version }}" - build-args: | - PYTHON_VER=${{ env.PYTHON_VER }} - - name: "Debug: Show docker images" - run: "docker image ls" - name: "Run Tests" run: "poetry run invoke pytest" publish_gh: