From 47cf0db3efe4efbea6b73d1abcc834820542f370 Mon Sep 17 00:00:00 2001 From: Matthias Dellweg Date: Mon, 27 Nov 2023 16:02:41 +0100 Subject: [PATCH] Fix script in release workflow While at it added yamllint to find at least some issues with the workflow files early. [noissue] --- .github/workflows/lint.yml | 4 ++++ templates/github/.github/workflows/ci.yml.j2 | 12 ++++++++---- .../.github/workflows/codeql-analysis.yml.j2 | 16 ++++++++-------- templates/github/.github/workflows/kanban.yml.j2 | 2 +- templates/github/.github/workflows/lint.yml.j2 | 14 +++++++++----- .../github/.github/workflows/nightly.yml.j2 | 8 ++++---- .../github/.github/workflows/release.yml.j2 | 4 ++-- .../.github/workflows/update-labels.yml.j2 | 10 +++++----- .../github/.github/workflows/update_ci.yml.j2 | 2 +- templates/github/lint_requirements.txt.j2 | 1 + 10 files changed, 43 insertions(+), 30 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 3bb9f6e9..10206818 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -45,6 +45,10 @@ jobs: - name: Install requirements run: pip3 install -r lint_requirements.txt + - name: Lint workflow files + run: | + yamllint -s -d '{extends: relaxed, rules: {line-length: disable}}' .github/workflows + # run black separately from flake8 to get a diff - name: Run black run: | diff --git a/templates/github/.github/workflows/ci.yml.j2 b/templates/github/.github/workflows/ci.yml.j2 index e5f3818c..8a3a0f04 100644 --- a/templates/github/.github/workflows/ci.yml.j2 +++ b/templates/github/.github/workflows/ci.yml.j2 @@ -23,9 +23,11 @@ defaults: working-directory: "{{ plugin_name }}" jobs: -{% if pre_job_template -%}{{ " " | indent }}{% include pre_job_template.path %}{%- endif %} - + {%- if pre_job_template %} + {% include pre_job_template.path %} + {%- endif %} {%- if check_commit_message or lint_requirements %} + ready-to-ship: runs-on: ubuntu-latest steps: @@ -56,8 +58,8 @@ jobs: test: needs: build uses: "./.github/workflows/test.yml" - {%- if test_deprecations %} + deprecations: defaults: run: @@ -93,4 +95,6 @@ jobs: {%- endif %} {%- endif %} -{% if post_job_template -%}{{ " " | indent }}{% include post_job_template.path %}{%- endif %} +{%- if post_job_template %} + {% include post_job_template.path %} +{%- endif %} diff --git a/templates/github/.github/workflows/codeql-analysis.yml.j2 b/templates/github/.github/workflows/codeql-analysis.yml.j2 index b437cc47..aaf0e779 100644 --- a/templates/github/.github/workflows/codeql-analysis.yml.j2 +++ b/templates/github/.github/workflows/codeql-analysis.yml.j2 @@ -25,13 +25,13 @@ jobs: language: [ 'python' ] steps: - - name: Checkout repository - uses: actions/checkout@v3 + - name: Checkout repository + uses: actions/checkout@v3 - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - with: - languages: {{ '${{ matrix.language }}' }} + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: {{ '${{ matrix.language }}' }} - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 diff --git a/templates/github/.github/workflows/kanban.yml.j2 b/templates/github/.github/workflows/kanban.yml.j2 index d19172f8..003822b6 100644 --- a/templates/github/.github/workflows/kanban.yml.j2 +++ b/templates/github/.github/workflows/kanban.yml.j2 @@ -53,7 +53,7 @@ jobs: runs-on: ubuntu-latest name: Find issues linked to a PR outputs: - linked-issues: {{ "${{ steps.linked-issues.outputs.issues }}" }} + linked-issues: {{ "${{ steps.linked-issues.outputs.issues }}" }} steps: - name: Checkout uses: actions/checkout@v2 diff --git a/templates/github/.github/workflows/lint.yml.j2 b/templates/github/.github/workflows/lint.yml.j2 index db42d4f4..4e7381ba 100644 --- a/templates/github/.github/workflows/lint.yml.j2 +++ b/templates/github/.github/workflows/lint.yml.j2 @@ -28,15 +28,19 @@ jobs: - name: Install requirements run: pip3 install -r lint_requirements.txt - {% if black -%} + - name: Lint workflow files + run: | + yamllint -s -d '{extends: relaxed, rules: {line-length: disable}}' .github/workflows + {%- if black %} + # run black separately from flake8 to get a diff - name: Run black run: | black --version black --check --diff . {%- endif %} + {%- if flake8 %} - {% if flake8 -%} # Lint code. - name: Run flake8 run: flake8 @@ -44,19 +48,19 @@ jobs: - name: Run extra lint checks run: "[ ! -x .ci/scripts/extra_linting.sh ] || .ci/scripts/extra_linting.sh" + {%- if check_manifest %} - {% if check_manifest -%} # check for any files unintentionally left out of MANIFEST.in - name: Check manifest run: check-manifest {%- endif %} + {%- if check_stray_pulpcore_imports %} - {% if check_stray_pulpcore_imports -%} - name: Check for pulpcore imports outside of pulpcore.plugin run: sh .ci/scripts/check_pulpcore_imports.sh {%- endif %} + {%- if check_gettext %} - {% if check_gettext -%} - name: Check for gettext problems run: sh .ci/scripts/check_gettext.sh {%- endif %} diff --git a/templates/github/.github/workflows/nightly.yml.j2 b/templates/github/.github/workflows/nightly.yml.j2 index 7c84a802..e1ab808d 100644 --- a/templates/github/.github/workflows/nightly.yml.j2 +++ b/templates/github/.github/workflows/nightly.yml.j2 @@ -67,8 +67,6 @@ jobs: steps: {{ checkout(path=plugin_name) | indent(6) }} - {{ checkout(repository="pulp/pulp-openapi-generator", path="pulp-openapi-generator") | indent(6) }} - - uses: actions/download-artifact@v3 with: name: "plugin_package" @@ -76,9 +74,11 @@ jobs: {{ setup_python() | indent(6) }} + {{ install_python_deps("requests") | indent(6) }} + {{ setup_env() | indent(6) }} + {%- if publish_docs_to_pulpprojectdotorg and docs_test %} - {% if publish_docs_to_pulpprojectdotorg and docs_test %} - name: Download built docs uses: actions/download-artifact@v3 with: @@ -97,7 +97,7 @@ jobs: run: | tar -xvf docs.tar -C ./docs .github/workflows/scripts/publish_docs.sh nightly ${GITHUB_REF##*/} - {% endif %} + {%- endif %} {{ display_logs() | indent(6) }} diff --git a/templates/github/.github/workflows/release.yml.j2 b/templates/github/.github/workflows/release.yml.j2 index f8abbee2..a0a80fff 100644 --- a/templates/github/.github/workflows/release.yml.j2 +++ b/templates/github/.github/workflows/release.yml.j2 @@ -239,9 +239,9 @@ jobs: env: TAG_NAME: {{ '${{ inputs.release }}' }} with: - const { TAG_NAME } = process.env; - script: | + const { TAG_NAME } = process.env; + await github.rest.repos.createRelease({ owner: context.repo.owner, repo: context.repo.repo, diff --git a/templates/github/.github/workflows/update-labels.yml.j2 b/templates/github/.github/workflows/update-labels.yml.j2 index ef2b5840..9b1acea7 100644 --- a/templates/github/.github/workflows/update-labels.yml.j2 +++ b/templates/github/.github/workflows/update-labels.yml.j2 @@ -6,13 +6,13 @@ with context %} --- -name: {{ plugin_app_label | camel }} Update Labels +name: "{{ plugin_app_label | camel }} Update Labels" on: push: branches: - - main + - "main" paths: - - 'template_config.yml' + - "template_config.yml" jobs: update_backport_labels: @@ -21,8 +21,8 @@ jobs: {{ setup_python() | indent(6) }} {{ configure_git() | indent(6) }} {{ install_python_deps("requests pyyaml") | indent(6) }} - - uses: actions/checkout@v3 - - name: Update labels + - uses: "actions/checkout@v3" + - name: "Update labels" run: | python3 .github/workflows/scripts/update_backport_labels.py env: diff --git a/templates/github/.github/workflows/update_ci.yml.j2 b/templates/github/.github/workflows/update_ci.yml.j2 index 403117fb..1b691e4e 100644 --- a/templates/github/.github/workflows/update_ci.yml.j2 +++ b/templates/github/.github/workflows/update_ci.yml.j2 @@ -14,7 +14,7 @@ on: # * is a special character in YAML so you have to quote this string # runs at 2:30 UTC every Sunday - cron: '30 2 * * 0' - {% endif %} + {%- endif %} workflow_dispatch: jobs: diff --git a/templates/github/lint_requirements.txt.j2 b/templates/github/lint_requirements.txt.j2 index 8d1ef358..17f33e01 100644 --- a/templates/github/lint_requirements.txt.j2 +++ b/templates/github/lint_requirements.txt.j2 @@ -9,3 +9,4 @@ flake8 {% if black -%} flake8-black {% endif -%} +yamllint