Skip to content

Commit

Permalink
Merge pull request #241 from phac-nml/fix/ci
Browse files Browse the repository at this point in the history
Fix GitHub CI Tests
  • Loading branch information
apetkau committed Sep 14, 2023
2 parents e752f6e + 73e8d93 commit 1a2d7c4
Show file tree
Hide file tree
Showing 2 changed files with 165 additions and 154 deletions.
130 changes: 90 additions & 40 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
name: Galaxy Tool Linting and Tests for Push and PR
name: Galaxy Tool Linting and Tests for push and PR
on:
pull_request: # Run on all PRs
pull_request:
paths-ignore:
- '.github/**'
- 'deprecated/**'
- 'docs/**'
- '*'
push:
branches: # Run on any push to development or master
branches:
- development
- main
- master
paths-ignore:
- '.github/**'
- 'deprecated/**'
- 'docs/**'
- '*'
env:
GALAXY_FORK: galaxyproject
GALAXY_BRANCH: release_22.05
GALAXY_BRANCH: release_23.1
MAX_CHUNKS: 4
MAX_FILE_SIZE: 1M
concurrency:
Expand Down Expand Up @@ -49,17 +60,17 @@ jobs:
- name: Determine latest commit in the Galaxy repo
id: get-galaxy-sha
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@v1
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Cache .cache/pip
uses: actions/cache@v2
uses: actions/cache@v3
id: cache-pip
with:
path: ~/.cache/pip
key: pip_cache_py_${{ matrix.python-version }}_gxy_${{ steps.get-galaxy-sha.outputs.galaxy-head-sha }}
- name: Cache .planemo
uses: actions/cache@v2
uses: actions/cache@v3
id: cache-planemo
with:
path: ~/.planemo
Expand All @@ -70,7 +81,7 @@ jobs:
run: pip install wheel
- name: Install flake8
run: pip install flake8 flake8-import-order
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Fake a Planemo run to update cache and determine commit range, repositories, and chunks
Expand Down Expand Up @@ -103,26 +114,36 @@ jobs:
matrix:
python-version: ['3.7']
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 1
- uses: actions/setup-python@v1
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Cache .cache/pip
uses: actions/cache@v2
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: 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@v2
- uses: actions/upload-artifact@v3
if: ${{ failure() }}
with:
name: 'Tool linting output'
Expand All @@ -132,21 +153,21 @@ 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
matrix:
python-version: ['3.7']
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 1
- uses: actions/setup-python@v1
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Cache .cache/pip
uses: actions/cache@v2
uses: actions/cache@v3
id: cache-pip
with:
path: ~/.cache/pip
Expand All @@ -155,7 +176,7 @@ jobs:
run: pip install flake8 flake8-import-order
- name: Flake8
run: echo '${{ needs.setup.outputs.repository-list }}' | xargs -d '\n' flake8 --output-file pylint_report.txt --tee
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
if: ${{ failure() }}
with:
name: 'Python linting output'
Expand All @@ -164,21 +185,21 @@ 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:
os: [ubuntu-20.04]
r-version: ['release']
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 1
- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.r-version }}
- name: Cache R packages
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ${{ env.R_LIBS_USER }}
key: r_cache_${{ matrix.os }}_${{ matrix.r-version }}
Expand All @@ -194,7 +215,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) {
Expand All @@ -214,7 +235,7 @@ jobs:
}
quit(status = status)
shell: Rscript {0}
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
if: ${{ failure() }}
with:
name: 'R linting output'
Expand All @@ -226,7 +247,7 @@ jobs:
if: ${{ github.event_name == 'pull_request' && needs.setup.outputs.repository-list != '' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Check file sizes
Expand All @@ -241,7 +262,7 @@ jobs:
cat file_size_report.txt
exit 1
fi
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
if: ${{ failure() }}
with:
name: 'File size report'
Expand Down Expand Up @@ -269,27 +290,29 @@ jobs:
ports:
- 5432:5432
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 1
- uses: actions/setup-python@v1
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Cache .cache/pip
uses: actions/cache@v2
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: Cache .planemo
uses: actions/cache@v2
uses: actions/cache@v3
id: cache-planemo
with:
path: ~/.planemo
key: planemo_cache_py_${{ matrix.python-version }}_gxy_${{ needs.setup.outputs.galaxy-head-sha }}
- 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
Expand All @@ -302,8 +325,8 @@ jobs:
chunk-count: ${{ needs.setup.outputs.chunk-count }}
galaxy-slots: ${{ steps.cpu-cores.outputs.count }}
# Limit each test to 15 minutes
test_timeout: 900
- uses: actions/upload-artifact@v2
test_timeout: 1800
- uses: actions/upload-artifact@v3
with:
name: 'Tool test output ${{ matrix.chunk }}'
path: upload
Expand All @@ -316,20 +339,20 @@ 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:
python-version: ['3.7']
steps:
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v3
with:
path: artifacts
- uses: actions/setup-python@v1
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Cache .cache/pip
uses: actions/cache@v2
uses: actions/cache@v3
id: cache-pip
with:
path: ~/.cache/pip
Expand All @@ -340,7 +363,7 @@ jobs:
with:
mode: combine
html-report: true
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
with:
name: 'All tool test results'
path: upload
Expand All @@ -349,25 +372,31 @@ 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:
name: Deploy
needs: [setup, lint, flake8, lintr, combine_outputs]
needs: [setup, lint, combine_outputs]
if: ${{ (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' ) && github.repository_owner == 'phac-nml' }}
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.7']
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 1
- uses: actions/setup-python@v1
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Cache .cache/pip
uses: actions/cache@v2
uses: actions/cache@v3
id: cache-pip
with:
path: ~/.cache/pip
Expand All @@ -388,6 +417,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 == 'phac-nml' }}
runs-on: ubuntu-latest
steps:
# report to the PR if deployment failed
- name: Get PR object
uses: 8BitJonny/[email protected]
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]
Expand All @@ -409,4 +460,3 @@ jobs:
- name: Check tool test status
if: ${{ needs.combine_outputs.result != 'success' && needs.combine_outputs.result != 'skipped' }}
run: exit 1

Loading

0 comments on commit 1a2d7c4

Please sign in to comment.