Skip to content

Commit

Permalink
Merge pull request #3042 from mashehu/run-aws-fulltest-only-after-two…
Browse files Browse the repository at this point in the history
…-reviews

Template: Run awsfulltest on PRs to `master` with two PR approvals
  • Loading branch information
mashehu committed Jul 9, 2024
2 parents 1dad57a + 48981f2 commit ecfe0fb
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Template

- Change paths to test data ([#2985](https://github.com/nf-core/tools/pull/2985))
- Run awsfulltest on PRs to `master` with two PR approvals ([#3042](https://github.com/nf-core/tools/pull/3042))
- Remove deprecated syntax ([#3046](https://github.com/nf-core/tools/pull/3046))

### Linting
Expand Down
23 changes: 19 additions & 4 deletions nf_core/pipeline-template/.github/workflows/awsfulltest.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,33 @@
name: nf-core AWS full size tests
# This workflow is triggered on published releases.
# This workflow is triggered on PRs opened against the master branch.
# It can be additionally triggered manually with GitHub actions workflow dispatch button.
# It runs the -profile 'test_full' on AWS batch

on:
release:
types: [published]
pull_request:
branches:
- master
workflow_dispatch:
pull_request_review:
types: [submitted]

jobs:
run-platform:
name: Run AWS full tests
if: github.repository == '{{ name }}'
if: github.repository == '{{ name }}' && github.event.review.state == 'approved'
runs-on: ubuntu-latest
steps:
- uses: octokit/request-action@v2.x
id: check_approvals
with:
route: GET /repos/{%- raw -%}${{ github.repository }}/pulls/${{ github.event.review.number }}/reviews
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- id: test_variables
run: |
JSON_RESPONSE='${{ steps.check_approvals.outputs.data }}'{% endraw %}
CURRENT_APPROVALS_COUNT=$(echo $JSON_RESPONSE | jq -c '[.[] | select(.state | contains("APPROVED")) ] | length')
test $CURRENT_APPROVALS_COUNT -ge 2 || exit 1 # At least 2 approvals are required
- name: Launch workflow via Seqera Platform
uses: seqeralabs/action-tower-launch@v2
# TODO nf-core: You can customise AWS full pipeline tests as required
Expand Down
4 changes: 3 additions & 1 deletion nf_core/pipelines/lint/actions_awsfulltest.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ def actions_awsfulltest(self):

# Check that the action is only turned on for published releases
try:
if wf[True]["release"]["types"] != ["published"]:
if wf[True]["pull_request"]["branches"] != ["master"]:
raise AssertionError()
if wf[True]["pull_request_review"]["types"] != ["submitted"]:
raise AssertionError()
if "workflow_dispatch" not in wf[True]:
raise AssertionError()
Expand Down
16 changes: 8 additions & 8 deletions tests/lint/actions_awsfulltest.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import os
from pathlib import Path

import yaml

import nf_core.pipelines.lint


def test_actions_awsfulltest_warn(self):
"""Lint test: actions_awsfulltest - WARN"""
"""Lint test: actions_awsfulltest - PASS"""
self.lint_obj._load()
results = self.lint_obj.actions_awsfulltest()
assert "`.github/workflows/awsfulltest.yml` is triggered correctly" in results["passed"]
Expand All @@ -15,14 +15,14 @@ def test_actions_awsfulltest_warn(self):


def test_actions_awsfulltest_pass(self):
"""Lint test: actions_awsfulltest - PASS"""
"""Lint test: actions_awsfulltest - WARN"""

# Edit .github/workflows/awsfulltest.yml to use -profile test_full
new_pipeline = self._make_pipeline_copy()
with open(os.path.join(new_pipeline, ".github", "workflows", "awsfulltest.yml")) as fh:
with open(Path(new_pipeline, ".github", "workflows", "awsfulltest.yml")) as fh:
awsfulltest_yml = fh.read()
awsfulltest_yml = awsfulltest_yml.replace("-profile test ", "-profile test_full ")
with open(os.path.join(new_pipeline, ".github", "workflows", "awsfulltest.yml"), "w") as fh:
with open(Path(new_pipeline, ".github", "workflows", "awsfulltest.yml"), "w") as fh:
fh.write(awsfulltest_yml)

# Make lint object
Expand All @@ -44,10 +44,10 @@ def test_actions_awsfulltest_fail(self):

# Edit .github/workflows/awsfulltest.yml to use -profile test_full
new_pipeline = self._make_pipeline_copy()
with open(os.path.join(new_pipeline, ".github", "workflows", "awsfulltest.yml")) as fh:
with open(Path(new_pipeline, ".github", "workflows", "awsfulltest.yml")) as fh:
awsfulltest_yml = yaml.safe_load(fh)
del awsfulltest_yml[True]["release"]
with open(os.path.join(new_pipeline, ".github", "workflows", "awsfulltest.yml"), "w") as fh:
del awsfulltest_yml[True]["pull_request_review"]
with open(Path(new_pipeline, ".github", "workflows", "awsfulltest.yml"), "w") as fh:
yaml.dump(awsfulltest_yml, fh)

# Make lint object
Expand Down

0 comments on commit ecfe0fb

Please sign in to comment.