From 24518dfa329002e961f2e92a3e5ca94a2e790dea Mon Sep 17 00:00:00 2001 From: Massimiliano Pippi Date: Fri, 14 Jun 2024 16:01:37 +0200 Subject: [PATCH] ci: merge linting steps into the test workflow (#7866) * move license header check under format * merge linting into test workflow * test commit to trigger CI * Revert "test commit to trigger CI" This reverts commit ade5dcc6873cdd29ff5c5e8c9033b137cdef4d81. * remove unused skipper --- .github/workflows/linting.yml | 85 --------------------------- .github/workflows/linting_skipper.yml | 29 --------- .github/workflows/tests.yml | 76 +++++++++++++++++++++++- 3 files changed, 74 insertions(+), 116 deletions(-) delete mode 100644 .github/workflows/linting.yml delete mode 100644 .github/workflows/linting_skipper.yml diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml deleted file mode 100644 index e264d98ad3..0000000000 --- a/.github/workflows/linting.yml +++ /dev/null @@ -1,85 +0,0 @@ -# If you change this name also do it in linting-skipper.yml and ci_metrics.yml -name: Linting - -on: - pull_request: - paths: - - "haystack/**/*.py" - - "test/**/*.py" - - "e2e/**/*.py" - - "pyproject.toml" - -env: - PYTHON_VERSION: "3.8" - HATCH_VERSION: "1.9.3" - -jobs: - license-header: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Check License Header - run: docker run --rm -v "$(pwd):/github/workspace" ghcr.io/korandoru/hawkeye check - - mypy: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - # With the default value of 1, there are corner cases where tj-actions/changed-files - # fails with a `no merge base` error - fetch-depth: 0 - - - name: Get changed files - id: files - uses: tj-actions/changed-files@v44 - with: - files: | - **/*.py - files_ignore: | - test/** - - - uses: actions/setup-python@v5 - with: - python-version: "${{ env.PYTHON_VERSION }}" - - - name: Install Hatch - run: pip install hatch==${{ env.HATCH_VERSION }} - - - name: Mypy - if: steps.files.outputs.any_changed == 'true' - run: | - mkdir .mypy_cache - hatch run test:types ${{ steps.files.outputs.all_changed_files }} - - pylint: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - # With the default value of 1, there are corner cases where tj-actions/changed-files - # fails with a `no merge base` error - fetch-depth: 0 - - - name: Get changed files - id: files - uses: tj-actions/changed-files@v44 - with: - files: | - haystack/**/*.py - - - uses: actions/setup-python@v5 - with: - python-version: "${{ env.PYTHON_VERSION }}" - - - name: Install Hatch - run: pip install hatch==${{ env.HATCH_VERSION }} - - - name: Pylint - if: steps.files.outputs.any_changed == 'true' - run: | - hatch run test:lint ${{ steps.files.outputs.all_changed_files }} diff --git a/.github/workflows/linting_skipper.yml b/.github/workflows/linting_skipper.yml deleted file mode 100644 index a48767b873..0000000000 --- a/.github/workflows/linting_skipper.yml +++ /dev/null @@ -1,29 +0,0 @@ -# If you change this name also do it in linting.yml and ci_metrics.yml -name: Linting - -on: - pull_request: - paths-ignore: - - "haystack/preview/**/*.py" - - "test/preview/**/*.py" - - "e2e/preview/**/*.py" - - "**/pyproject.toml" - -jobs: - license-header: - runs-on: ubuntu-latest - steps: - - name: Skip mypy - run: echo "Skipped mypy" - - mypy: - runs-on: ubuntu-latest - steps: - - name: Skip mypy - run: echo "Skipped mypy" - - pylint: - runs-on: ubuntu-latest - steps: - - name: Skip pylint - run: echo "Skipped pylint" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 690c51ff30..633210ee07 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -45,9 +45,81 @@ jobs: - name: Install Hatch run: pip install hatch==${{ env.HATCH_VERSION }} - - name: Check status + - name: Check file format run: hatch run format + - name: Check presence of license header + run: docker run --rm -v "$(pwd):/github/workspace" ghcr.io/korandoru/hawkeye check + + - name: Calculate alert data + id: calculator + shell: bash + if: (success() || failure()) && github.ref_name == 'main' + run: | + if [ "${{ job.status }}" = "success" ]; then + echo "alert_type=success" >> "$GITHUB_OUTPUT"; + else + echo "alert_type=error" >> "$GITHUB_OUTPUT"; + fi + + - name: Send event to Datadog + if: (success() || failure()) && github.ref_name == 'main' + uses: masci/datadog@v1 + with: + api-key: ${{ secrets.CORE_DATADOG_API_KEY }} + api-url: https://api.datadoghq.eu + events: | + - title: "${{ github.workflow }} workflow" + text: "Job ${{ github.job }} in branch ${{ github.ref_name }}" + alert_type: "${{ steps.calculator.outputs.alert_type }}" + source_type_name: "Github" + host: ${{ github.repository_owner }} + tags: + - "project:${{ github.repository }}" + - "job:${{ github.job }}" + - "run_id:${{ github.run_id }}" + - "workflow:${{ github.workflow }}" + - "branch:${{ github.ref_name }}" + - "url:https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" + + lint: + needs: format + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + # With the default value of 1, there are corner cases where tj-actions/changed-files + # fails with a `no merge base` error + fetch-depth: 0 + + - name: Get changed files + id: files + uses: tj-actions/changed-files@v44 + with: + files: | + **/*.py + files_ignore: | + test/** + + - uses: actions/setup-python@v5 + with: + python-version: "${{ env.PYTHON_VERSION }}" + + - name: Install Hatch + run: pip install hatch==${{ env.HATCH_VERSION }} + + - name: Mypy + if: steps.files.outputs.any_changed == 'true' + run: | + mkdir .mypy_cache + hatch run test:types ${{ steps.files.outputs.all_changed_files }} + + - name: Pylint + if: steps.files.outputs.any_changed == 'true' + run: | + hatch run test:lint ${{ steps.files.outputs.all_changed_files }} + - name: Calculate alert data id: calculator shell: bash @@ -81,7 +153,7 @@ jobs: unit-tests: name: Unit / ${{ matrix.os }} - needs: format + needs: lint strategy: fail-fast: false matrix: