name: nf-core AWS full size tests
# This workflow is triggered on PRs opened against the main/master branch.
# It can be additionally triggered manually with GitHub actions workflow dispatch button.
# It runs the -profile 'test_full' on AWS batch

on:
  workflow_dispatch:
  pull_request_review:
    types: [submitted]
  release:
    types: [published]

jobs:
  run-platform:
    name: Run AWS full tests
    # run only if the PR is approved by at least 2 reviewers and against the master/main branch or manually triggered
    if: github.repository == '{{ name }}' && github.event.review.state == 'approved' && (github.event.pull_request.base.ref == 'master' || github.event.pull_request.base.ref == 'main') || github.event_name == 'workflow_dispatch' || github.event_name == 'release'
    runs-on: ubuntu-latest
    steps:
      - name: Set revision variable
        id: revision
        run: |
          echo "revision={%- raw -%}${{ (github.event_name == 'workflow_dispatch' || github.event_name == 'release') && github.sha || 'dev' }}" >> "$GITHUB_OUTPUT"

      - name: Launch workflow via Seqera Platform
        uses: seqeralabs/action-tower-launch@v2
        # TODO nf-core: You can customise AWS full pipeline tests as required
        # Add full size test data (but still relatively small datasets for few samples)
        # on the `test_full.config` test runs with only one set of parameters
        with:
          workspace_id: ${{ secrets.TOWER_WORKSPACE_ID }}
          access_token: ${{ secrets.TOWER_ACCESS_TOKEN }}
          compute_env: ${{ secrets.TOWER_COMPUTE_ENV }}
          revision: ${{ steps.revision.outputs.revision }}
          workdir: s3://${{ secrets.AWS_S3_BUCKET }}{% endraw %}/work/{{ short_name }}/{% raw %}work-${{ steps.revision.outputs.revision }}{% endraw %}
          parameters: |
            {
              "hook_url": "{% raw %}${{ secrets.MEGATESTS_ALERTS_SLACK_HOOK_URL }}{% endraw %}",
              "outdir": "s3://{% raw %}${{ secrets.AWS_S3_BUCKET }}{% endraw %}/{{ short_name }}/{% raw %}results-${{ steps.revision.outputs.revision }}{% endraw %}"
            }
          profiles: test_full

      - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
        with:
          name: Seqera Platform debug log file
          path: |
            seqera_platform_action_*.log
            seqera_platform_action_*.json
