From 8232947f9c2ceef36056f7fd5d11bd87b83760df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20H=C3=B6rtenhuber?= Date: Thu, 12 Dec 2024 11:44:45 +0100 Subject: [PATCH] dev -> main for 3.1.0 (#3336) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * set default_branch to master for now * update changelog * set git defaultBranch to master in sync action * update changelog * use nextflow.config to set defaultBranch * fix path for nextflow.config grep * change working dir when setting defaultBranch * fix Changelog * Be more verbose in approval check action * fix if clause * update changelog * add verbose mode to sync action * update changelog * Apply suggestions from code review * add input debug for workflow_dispatch sync action * go back to original directory after configuring git defaultBranch * add more debugging on sync GHA * echo message to sync GHA * try exiting pipeline directory before saving defaultBranch * cleanup debugging echo * use same ref in checkout as triggered the workflow * don't set up loggin level to error * Revert "don't set up loggin level to error [no changelog]" * Update nf_core/pipeline-template/.github/workflows/awsfulltest.yml --------- Co-authored-by: JĂșlia Mir Pedrol --- .github/workflows/sync.yml | 23 ++++++++++++++++++- CHANGELOG.md | 4 ++++ .../.github/workflows/awsfulltest.yml | 15 ++++++++++-- nf_core/pipeline-template/nextflow.config | 2 +- nf_core/pipelines/create/create.py | 8 +++---- 5 files changed, 44 insertions(+), 8 deletions(-) diff --git a/.github/workflows/sync.yml b/.github/workflows/sync.yml index 625f00d247..7061294783 100644 --- a/.github/workflows/sync.yml +++ b/.github/workflows/sync.yml @@ -23,6 +23,10 @@ on: description: "Pipeline to sync" type: string default: "all" + debug: + description: "Enable debug/verbose mode (true or false)" + type: boolean + default: false # Cancel if a newer run is started concurrency: @@ -62,6 +66,8 @@ jobs: steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 name: Check out nf-core/tools + with: + ref: ${{ github.ref_name }} - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 name: Check out nf-core/${{ matrix.pipeline }} @@ -87,6 +93,19 @@ jobs: with: version: "latest-everything" + - name: Set Git default branch from nextflow.config and set git default branch to that or "master" + + run: | + pushd nf-core/${{ matrix.pipeline }} + defaultBranch=$(grep -B5 -A5 "nextflowVersion" nextflow.config | grep "defaultBranch" | cut -d"=" -f2) + if [ -z "$defaultBranch" ]; then + defaultBranch="master" + fi + popd + echo "Default branch: $defaultBranch" + echo "defaultBranch=$defaultBranch" >> GITHUB_OUTPUT + git config --global init.defaultBranch $defaultBranch + - name: Run synchronisation if: github.repository == 'nf-core/tools' env: @@ -94,7 +113,9 @@ jobs: run: | git config --global user.email "core@nf-co.re" git config --global user.name "nf-core-bot" - nf-core --log-file sync_log_${{ matrix.pipeline }}.txt pipelines sync -d nf-core/${{ matrix.pipeline }} \ + nf-core --log-file sync_log_${{ matrix.pipeline }}.txt \ + ${{ github.event.inputs.debug == 'true' && '--verbose' || '' }} \ + pipelines sync -d nf-core/${{ matrix.pipeline }} \ --from-branch dev \ --pull-request \ --username nf-core-bot \ diff --git a/CHANGELOG.md b/CHANGELOG.md index 9015ac6daa..603fa77e24 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ - Add `manifest.contributors` to `nextflow.config` ([#3311](https://github.com/nf-core/tools/pull/3311)) - Update template components ([#3328](https://github.com/nf-core/tools/pull/3328)) - Template: Remove mention of GRCh37 if igenomes is skipped ([#3330](https://github.com/nf-core/tools/pull/3330)) +- Be more verbose in approval check action ([#3338](https://github.com/nf-core/tools/pull/3338)) ### Download @@ -65,6 +66,9 @@ - Don't break gitpod.yml with template string ([#3332](https://github.com/nf-core/tools/pull/3332)) - rocrate: remove duplicated entries for name and version ([#3333](https://github.com/nf-core/tools/pull/3333)) - rocrate: Update crate with version bump and handle new contributor field ([#3334](https://github.com/nf-core/tools/pull/3334)) +- set default_branch to master for now ([#3335](https://github.com/nf-core/tools/issues/3335)) +- Set git defaultBranch to master in sync action ([#3337](https://github.com/nf-core/tools/pull/3337)) +- Add verbose mode to sync action ([#3339](https://github.com/nf-core/tools/pull/3339)) ### Version updates diff --git a/nf_core/pipeline-template/.github/workflows/awsfulltest.yml b/nf_core/pipeline-template/.github/workflows/awsfulltest.yml index 45c2a0e555..6805c83a27 100644 --- a/nf_core/pipeline-template/.github/workflows/awsfulltest.yml +++ b/nf_core/pipeline-template/.github/workflows/awsfulltest.yml @@ -19,19 +19,30 @@ jobs: if: github.repository == '{{ name }}' && github.event.review.state == 'approved' && github.event.pull_request.base.ref == 'master' || github.event_name == 'workflow_dispatch' runs-on: ubuntu-latest steps: - - uses: octokit/request-action@v2.x + - name: Get PR reviews + uses: octokit/request-action@v2.x if: github.event_name != 'workflow_dispatch' id: check_approvals + continue-on-error: true with: route: GET /repos/{%- raw -%}${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/reviews?per_page=100 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - id: test_variables + + - name: Check for approvals + if: ${{ failure() && github.event_name != 'workflow_dispatch' }} + run: | + echo "No review approvals found. At least 2 approvals are required to run this action automatically." + exit 1 + + - name: Check for enough approvals (>=2) + id: test_variables if: github.event_name != 'workflow_dispatch' 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 diff --git a/nf_core/pipeline-template/nextflow.config b/nf_core/pipeline-template/nextflow.config index 000d7cd664..36018b1062 100644 --- a/nf_core/pipeline-template/nextflow.config +++ b/nf_core/pipeline-template/nextflow.config @@ -327,7 +327,7 @@ validation { https://doi.org/10.1038/s41587-020-0439-x * Software dependencies - https://github.com/{{ name }}/blob/master/CITATIONS.md + https://github.com/{{ name }}/blob/{{ default_branch }}/CITATIONS.md """{% endif %} }{% if is_nfcore %} summary { diff --git a/nf_core/pipelines/create/create.py b/nf_core/pipelines/create/create.py index 8855f2dae3..0e2c683e6f 100644 --- a/nf_core/pipelines/create/create.py +++ b/nf_core/pipelines/create/create.py @@ -57,7 +57,7 @@ def __init__( template_config: Optional[Union[CreateConfig, str, Path]] = None, organisation: str = "nf-core", from_config_file: bool = False, - default_branch: str = "main", + default_branch: str = "master", is_interactive: bool = False, ) -> None: if isinstance(template_config, CreateConfig): @@ -298,7 +298,6 @@ def render_template(self) -> None: template_dir = Path(nf_core.__file__).parent / "pipeline-template" object_attrs = self.jinja_params object_attrs["nf_core_version"] = nf_core.__version__ - # Can't use glob.glob() as need recursive hidden dotfiles - https://stackoverflow.com/a/58126417/713980 template_files = list(Path(template_dir).glob("**/*")) template_files += list(Path(template_dir).glob("*")) @@ -431,8 +430,9 @@ def get_default_branch(self) -> None: """Gets the default branch name from the Git configuration.""" try: self.default_branch = ( - str(git.config.GitConfigParser().get_value("init", "defaultBranch")) or "main" - ) # default to main + str(git.config.GitConfigParser().get_value("init", "defaultBranch")) or "master" + ) # default to master + log.debug(f"Default branch name: {self.default_branch}") except configparser.Error: log.debug("Could not read init.defaultBranch") if self.default_branch in ["dev", "TEMPLATE"]: