From 466362140873d98cfcab43b32b8bd08c418ae099 Mon Sep 17 00:00:00 2001 From: hechth Date: Thu, 14 Sep 2023 08:49:25 +0200 Subject: [PATCH] updated CI and PR github actions from IUC --- .github/workflows/ci.yaml | 52 +++++++++++++++++++++++++---- .github/workflows/pr.yaml | 69 +++++++++++++++++++++++++++++++++++---- 2 files changed, 107 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 40d2ebf3..be162c88 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -27,7 +27,7 @@ jobs: steps: - name: Add reaction if: ${{ github.event.client_payload.slash_command.command == 'run-all-tool-tests' }} - uses: peter-evans/create-or-update-comment@v1 + uses: peter-evans/create-or-update-comment@v2 with: token: ${{ secrets.PAT }} repository: ${{ github.event.client_payload.github.payload.repository.full_name }} @@ -37,12 +37,12 @@ jobs: id: get-fork-branch run: | TMP="${{ github.event.client_payload.slash_command.args.named.fork }}" - echo "::set-output name=fork::${TMP:-$GALAXY_FORK}" + echo "fork=${TMP:-$GALAXY_FORK}" >> $GITHUB_OUTPUT TMP="${{ github.event.client_payload.slash_command.args.named.branch }}" - echo "::set-output name=branch::${TMP:-$GALAXY_BRANCH}" + echo "branch=${TMP:-$GALAXY_BRANCH}" >> $GITHUB_OUTPUT - name: Determine latest commit in the Galaxy repo id: get-galaxy-sha - run: echo "::set-output name=galaxy-head-sha::$(git ls-remote https://github.com/${{ steps.get-fork-branch.outputs.fork }}/galaxy refs/heads/${{ steps.get-fork-branch.outputs.branch }} | cut -f1)" + run: echo "galaxy-head-sha=$(git ls-remote https://github.com/${{ steps.get-fork-branch.outputs.fork }}/galaxy refs/heads/${{ steps.get-fork-branch.outputs.branch }} | cut -f1)" >> $GITHUB_OUTPUT - uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} @@ -74,6 +74,42 @@ jobs: run: | echo 'Using ${{ steps.discover.outputs.chunk-count }} chunks (${{ steps.discover.outputs.chunk-list }})' + lint: + name: Check for missing containers + needs: setup + if: ${{ needs.setup.outputs.repository-list != '' || needs.setup.outputs.tool-list != '' }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: ['3.7'] + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 1 + - uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Cache .cache/pip + uses: actions/cache@v3 + id: cache-pip + with: + path: ~/.cache/pip + key: pip_cache_py_${{ matrix.python-version }}_gxy_${{ needs.setup.outputs.galaxy-head-sha }} + - name: Planemo lint + uses: galaxyproject/planemo-ci-action@v1 + id: lint + with: + mode: lint + repository-list: ${{ needs.setup.outputs.repository-list }} + tool-list: ${{ needs.setup.outputs.tool-list }} + additional-planemo-options: --biocontainers -s tests,output,inputs,help,general,command,citations,tool_xsd + - uses: actions/upload-artifact@v3 + if: ${{ failure() }} + with: + name: 'Tool linting output' + path: lint_report.txt + test: name: Test tools # This job runs on Linux @@ -112,6 +148,8 @@ jobs: - name: Get number of CPU cores uses: SimenB/github-actions-cpu-cores@v1 id: cpu-cores + - name: Clean dotnet folder for space + run: rm -Rf /usr/share/dotnet - name: Planemo test uses: galaxyproject/planemo-ci-action@v1 id: test @@ -169,11 +207,11 @@ jobs: - name: Create URL to the run output if: ${{ github.event.client_payload.slash_command.command == 'run-all-tool-tests' }} id: vars - run: echo "::set-output name=run-url::https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" + run: echo "run-url=https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" >> $GITHUB_OUTPUT - name: Create comment if: ${{ github.event.client_payload.slash_command.command == 'run-all-tool-tests' }} - uses: peter-evans/create-or-update-comment@v1 + uses: peter-evans/create-or-update-comment@v2 with: token: ${{ secrets.PAT }} repository: ${{ github.event.client_payload.github.payload.repository.full_name }} @@ -190,4 +228,4 @@ jobs: uses: galaxyproject/planemo-ci-action@v1 id: check with: - mode: check + mode: check \ No newline at end of file diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index debce3f9..dc183b1b 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -1,5 +1,20 @@ name: Galaxy Tool Linting and Tests for push and PR -on: [push, pull_request] +on: + pull_request: + paths-ignore: + - '.github/**' + - 'deprecated/**' + - 'docs/**' + - '*' + push: + branches: + - main + - master + paths-ignore: + - '.github/**' + - 'deprecated/**' + - 'docs/**' + - '*' env: GALAXY_FORK: galaxyproject GALAXY_BRANCH: release_22.05 @@ -43,7 +58,7 @@ jobs: echo 'event.after: ${{ github.event.after }}' - name: Determine latest commit in the Galaxy repo id: get-galaxy-sha - run: echo "::set-output name=galaxy-head-sha::$(git ls-remote https://github.com/${{ env.GALAXY_FORK }}/galaxy refs/heads/${{ env.GALAXY_BRANCH }} | cut -f1)" + run: echo "galaxy-head-sha=$(git ls-remote https://github.com/${{ env.GALAXY_FORK }}/galaxy refs/heads/${{ env.GALAXY_BRANCH }} | cut -f1)" >> $GITHUB_OUTPUT - uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} @@ -110,11 +125,21 @@ jobs: with: path: ~/.cache/pip key: pip_cache_py_${{ matrix.python-version }}_gxy_${{ needs.setup.outputs.galaxy-head-sha }} + + - name: Set fail level for pull request + if: ${{ github.event_name == 'pull_request' }} + run: + echo "FAIL_LEVEL=warn" >> "$GITHUB_ENV" + - name: Set fail level for merge + if: ${{ github.event_name != 'pull_request' }} + run: + echo "FAIL_LEVEL=error" >> "$GITHUB_ENV" - name: Planemo lint uses: galaxyproject/planemo-ci-action@v1 id: lint with: mode: lint + fail-level: ${{ env.FAIL_LEVEL }} repository-list: ${{ needs.setup.outputs.repository-list }} tool-list: ${{ needs.setup.outputs.tool-list }} - uses: actions/upload-artifact@v3 @@ -127,7 +152,7 @@ jobs: flake8: name: Lint Python scripts needs: setup - if: ${{ needs.setup.outputs.repository-list != '' }} + if: ${{ github.event_name == 'pull_request' && needs.setup.outputs.repository-list != '' }} runs-on: ubuntu-latest strategy: fail-fast: false @@ -159,7 +184,7 @@ jobs: lintr: name: Lint R scripts needs: setup - if: ${{ needs.setup.outputs.repository-list != '' }} + if: ${{ github.event_name == 'pull_request' && needs.setup.outputs.repository-list != '' }} runs-on: ${{ matrix.os }} strategy: matrix: @@ -189,7 +214,7 @@ jobs: - name: lintr run: | library(lintr) - linters <- linters_with_defaults(line_length_linter = NULL, cyclocomp_linter = NULL, object_usage_linter = NULL) + linters <- linters_with_defaults(line_length_linter = NULL, cyclocomp_linter = NULL, object_usage_linter = NULL, object_name_linter = NULL) con <- file("repository_list.txt", "r") status <- 0 while (TRUE) { @@ -285,6 +310,8 @@ jobs: - name: Get number of CPU cores uses: SimenB/github-actions-cpu-cores@v1 id: cpu-cores + - name: Clean dotnet folder for space + run: rm -Rf /usr/share/dotnet - name: Planemo test uses: galaxyproject/planemo-ci-action@v1 id: test @@ -311,7 +338,7 @@ jobs: combine_outputs: name: Combine chunked test results needs: [setup, test] - if: ${{ needs.setup.outputs.repository-list != '' }} + if: ${{ always() && needs.setup.outputs.repository-list != '' }} runs-on: ubuntu-latest strategy: matrix: @@ -344,6 +371,12 @@ jobs: id: check with: mode: check + - name: Check if all test chunks succeeded + run: | + NFILES=$(ls artifacts/ | grep "Tool test output" | wc -l) + if [[ "${{ needs.setup.outputs.chunk-count }}" != "$NFILES" ]]; then + exit 1 + fi # deploy the tools to the toolsheds (first TTS for testing) deploy: @@ -383,6 +416,28 @@ jobs: shed-target: toolshed shed-key: ${{ secrets.TS_API_KEY }} + deploy-report: + name: Report deploy status + needs: [deploy] + if: ${{ always() && needs.deploy.result != 'success' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' ) && github.repository_owner == 'RECETOX' }} + runs-on: ubuntu-latest + steps: + # report to the PR if deployment failed + - name: Get PR object + uses: 8BitJonny/gh-get-current-pr@2.2.0 + id: getpr + with: + sha: ${{ github.event.after }} + - name: Create comment + uses: peter-evans/create-or-update-comment@v2 + with: + token: ${{ secrets.PAT }} + issue-number: ${{ steps.getpr.outputs.number }} + body: | + Attention: deployment ${{ needs.deploy.result }}! + + https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} + determine-success: name: Check workflow success needs: [setup, lint, flake8, lintr, file_sizes, combine_outputs] @@ -403,4 +458,4 @@ jobs: run: exit 1 - name: Check tool test status if: ${{ needs.combine_outputs.result != 'success' && needs.combine_outputs.result != 'skipped' }} - run: exit 1 + run: exit 1 \ No newline at end of file