From 5ff50bfa2bf21452b0e72b5a5cfee91a4cbd29e1 Mon Sep 17 00:00:00 2001 From: "Y. Meyer-Norwood" <106889957+norwd@users.noreply.github.com> Date: Thu, 7 Nov 2024 15:10:16 +1300 Subject: [PATCH 01/15] Create workflow to unit test fmtya Signed-off-by: Y. Meyer-Norwood <106889957+norwd@users.noreply.github.com> --- .github/workflows/test.yml | 68 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..5990133 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,68 @@ +--- + +name: "Run Tests" +run-name: "Run Tests" + +on: + push: + +jobs: + + test_that_fmtya_can_run_on_itself: + name: "Test that fmtya can run on itself" + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: + - ubuntu-latest + - windows-latest + - macos-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Run fmtya + uses: ./ + with: + + # permission settings + token: ${{ secrets.SELF_FMTYA || secrets.GITHUB_TOKEN }} + + # commit information + commit-user-name: norwd + commit-user-email: 106889957+norwd@users.noreply.github.com + signing-private-key: ${{ secrets.AUTO_COMMIT_GPG_PRIVATE_KEY_FMTYA }} + signing-passphrase: ${{ secrets.AUTO_COMMIT_GPG_PASSPHRASE_FMTYA }} + signoff-on-commit: ${{ github.actor == github.repository_owner }} + + # yamlfmt configuration + exclude-files: .github/testing/bad.yml + include-files: | + **/*.{yaml,yml} + .github/testing/nonexisting.yml + + test_that_fmtya_should_report_missing_yamlfmt_version: + name: "Test that fmtya should report missing yamlfmt version" + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: + - ubuntu-latest + - windows-latest + - macos-latest + + steps: + - name: "Checkout" + uses: actions/checkout@v3 + + - id: test + continue-on-error: true + name: "Run fmtya" + uses: ./ + with: + yamlfmt-version: '' + + - name: "Assert" + if: steps.test.outcome != 'failure' + run: echo "::error title=Assertion Failed::Fmtya should report missing yamlfmt version" ; exit 1 From 19dc20c4e1e8372dc5ce34d35bef4b52593060ff Mon Sep 17 00:00:00 2001 From: "Y. Meyer-Norwood" <106889957+norwd@users.noreply.github.com> Date: Thu, 7 Nov 2024 15:11:14 +1300 Subject: [PATCH 02/15] Delete .github/workflows/self-test.yml Redundant with "Run Tests / Test that fmtya can run on itself" Signed-off-by: Y. Meyer-Norwood <106889957+norwd@users.noreply.github.com> --- .github/workflows/self-test.yml | 35 --------------------------------- 1 file changed, 35 deletions(-) delete mode 100644 .github/workflows/self-test.yml diff --git a/.github/workflows/self-test.yml b/.github/workflows/self-test.yml deleted file mode 100644 index 3d55ed2..0000000 --- a/.github/workflows/self-test.yml +++ /dev/null @@ -1,35 +0,0 @@ ---- - -name: "Self Test" -run-name: "Self Test workflow started by @${{ github.actor }}" - -on: - push: - -jobs: - run-self: - name: Run fmtya on itself - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Run fmtya - uses: ./ - with: - - # permission settings - token: ${{ secrets.SELF_FMTYA || secrets.GITHUB_TOKEN }} - - # commit information - commit-user-name: norwd - commit-user-email: 106889957+norwd@users.noreply.github.com - signing-private-key: ${{ secrets.AUTO_COMMIT_GPG_PRIVATE_KEY_FMTYA }} - signing-passphrase: ${{ secrets.AUTO_COMMIT_GPG_PASSPHRASE_FMTYA }} - signoff-on-commit: ${{ github.actor == github.repository_owner }} - - # yamlfmt configuration - exclude-files: .github/testing/bad.yml - include-files: | - **/*.{yaml,yml} - .github/testing/nonexisting.yml From 628b2b2fe3a9822e8cd66cc69b209d748b8124eb Mon Sep 17 00:00:00 2001 From: "Y. Meyer-Norwood" <106889957+norwd@users.noreply.github.com> Date: Thu, 7 Nov 2024 15:11:50 +1300 Subject: [PATCH 03/15] Always run all unit tests Signed-off-by: Y. Meyer-Norwood <106889957+norwd@users.noreply.github.com> --- .github/workflows/test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5990133..6bcd77e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,6 +9,7 @@ on: jobs: test_that_fmtya_can_run_on_itself: + if: always() name: "Test that fmtya can run on itself" runs-on: ${{ matrix.os }} strategy: @@ -43,6 +44,7 @@ jobs: .github/testing/nonexisting.yml test_that_fmtya_should_report_missing_yamlfmt_version: + if: always() name: "Test that fmtya should report missing yamlfmt version" runs-on: ${{ matrix.os }} strategy: From f073ae72bf17b0dfeac6a33d0aac64d37c8ba1ea Mon Sep 17 00:00:00 2001 From: "Y. Meyer-Norwood" <106889957+norwd@users.noreply.github.com> Date: Thu, 7 Nov 2024 15:13:51 +1300 Subject: [PATCH 04/15] Disable failfast and parallelism Signed-off-by: Y. Meyer-Norwood <106889957+norwd@users.noreply.github.com> --- .github/workflows/test.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6bcd77e..008829b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,6 +13,8 @@ jobs: name: "Test that fmtya can run on itself" runs-on: ${{ matrix.os }} strategy: + fail-fast: false + max-parallel: 1 matrix: os: - ubuntu-latest @@ -48,6 +50,8 @@ jobs: name: "Test that fmtya should report missing yamlfmt version" runs-on: ${{ matrix.os }} strategy: + fail-fast: false + max-parallel: 1 matrix: os: - ubuntu-latest From 5839f8d47f330dfa285f02311632d0ef6d788377 Mon Sep 17 00:00:00 2001 From: "Y. Meyer-Norwood" <106889957+norwd@users.noreply.github.com> Date: Thu, 7 Nov 2024 15:48:24 +1300 Subject: [PATCH 05/15] Use the latest version of `setup-go` Signed-off-by: Y. Meyer-Norwood <106889957+norwd@users.noreply.github.com> --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 30e94d1..68cdf3f 100644 --- a/action.yml +++ b/action.yml @@ -169,7 +169,7 @@ runs: token: ${{ inputs.token || github.token }} - name: "Setup Go" - uses: actions/setup-go@v4.0.0 + uses: actions/setup-go@v5.1.0 with: token: ${{ inputs.token || github.token }} From a0f1bf846af2f110e26a7ec661bcf993c251f2fc Mon Sep 17 00:00:00 2001 From: "Y. Meyer-Norwood" <106889957+norwd@users.noreply.github.com> Date: Thu, 7 Nov 2024 16:11:09 +1300 Subject: [PATCH 06/15] Explicitly use stable go version Signed-off-by: Y. Meyer-Norwood <106889957+norwd@users.noreply.github.com> --- action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/action.yml b/action.yml index 68cdf3f..8277083 100644 --- a/action.yml +++ b/action.yml @@ -172,6 +172,7 @@ runs: uses: actions/setup-go@v5.1.0 with: token: ${{ inputs.token || github.token }} + go-version: stable - name: "Install yamlfmt" shell: bash From ded271870023a642068c4fd2c286233b60842203 Mon Sep 17 00:00:00 2001 From: "Y. Meyer-Norwood" <106889957+norwd@users.noreply.github.com> Date: Thu, 7 Nov 2024 16:26:06 +1300 Subject: [PATCH 07/15] Use environment variables for config Signed-off-by: Y. Meyer-Norwood <106889957+norwd@users.noreply.github.com> --- action.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 8277083..262a0bc 100644 --- a/action.yml +++ b/action.yml @@ -145,8 +145,10 @@ runs: - name: "Configure yamlfmt" shell: bash + env: + CONFIG_FILE: '${{ runner.temp }}/yamlfmt.conf' run: | - cat << ${{ steps.config.outputs.delimiter }} | awk 'NF>0' | tee ${{ runner.temp }}/yamlfmt.conf + cat << ${{ steps.config.outputs.delimiter }} | awk 'NF>0' | tee ${CONFIG_FILE} ${{ steps.config.outputs.include-files && 'include: - '|| '' }}${{ join(fromJSON(steps.config.outputs.include-files), ' - ') || '' }} @@ -182,7 +184,9 @@ runs: - name: "Run yamlfmt" shell: bash - run: ~/go/bin/yamlfmt -conf "${{ runner.temp }}/yamlfmt.conf" + run: ~/go/bin/yamlfmt -conf "${CONFIG_FILE}" + env: + CONFIG_FILE: '${{ runner.temp }}/yamlfmt.conf' - name: "Setup GPG Keys" if: inputs.signing-private-key != '' From 382bb097dc38b9fe6052f4413126de05c758c945 Mon Sep 17 00:00:00 2001 From: "Y. Meyer-Norwood" <106889957+norwd@users.noreply.github.com> Date: Thu, 7 Nov 2024 16:44:25 +1300 Subject: [PATCH 08/15] Add support for windows path sep Signed-off-by: Y. Meyer-Norwood <106889957+norwd@users.noreply.github.com> --- action.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/action.yml b/action.yml index 262a0bc..d374db0 100644 --- a/action.yml +++ b/action.yml @@ -145,10 +145,8 @@ runs: - name: "Configure yamlfmt" shell: bash - env: - CONFIG_FILE: '${{ runner.temp }}/yamlfmt.conf' run: | - cat << ${{ steps.config.outputs.delimiter }} | awk 'NF>0' | tee ${CONFIG_FILE} + cat << ${{ steps.config.outputs.delimiter }} | awk 'NF>0' | tee "${CONFIG_FILE}" ${{ steps.config.outputs.include-files && 'include: - '|| '' }}${{ join(fromJSON(steps.config.outputs.include-files), ' - ') || '' }} @@ -163,6 +161,8 @@ runs: retain_line_breaks: ${{ inputs.keep-line-breaks }} disallow_anchors: ${{ inputs.disallow-anchors }} ${{ steps.config.outputs.delimiter }} + env: + CONFIG_FILE: ${{ format('{0}{1}yamlfmt.conf', runner.temp, contains(runner.temp, '\') && '\' || '/') }} - name: "Checkout" uses: actions/checkout@v3.3.0 @@ -186,7 +186,7 @@ runs: shell: bash run: ~/go/bin/yamlfmt -conf "${CONFIG_FILE}" env: - CONFIG_FILE: '${{ runner.temp }}/yamlfmt.conf' + CONFIG_FILE: ${{ format('{0}{1}yamlfmt.conf', runner.temp, contains(runner.temp, '\') && '\' || '/') }} - name: "Setup GPG Keys" if: inputs.signing-private-key != '' From 4b4ea2e4b7f486ea917c833be94fa799f40baf64 Mon Sep 17 00:00:00 2001 From: "Y. Meyer-Norwood" <106889957+norwd@users.noreply.github.com> Date: Thu, 7 Nov 2024 16:48:04 +1300 Subject: [PATCH 09/15] Don't cache go setup Signed-off-by: Y. Meyer-Norwood <106889957+norwd@users.noreply.github.com> --- action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/action.yml b/action.yml index d374db0..b5d3430 100644 --- a/action.yml +++ b/action.yml @@ -175,6 +175,7 @@ runs: with: token: ${{ inputs.token || github.token }} go-version: stable + cache: false - name: "Install yamlfmt" shell: bash From 431daaa47967e3462607d6f90cfdd9e1760c1d0b Mon Sep 17 00:00:00 2001 From: "Y. Meyer-Norwood" <106889957+norwd@users.noreply.github.com> Date: Thu, 7 Nov 2024 17:04:31 +1300 Subject: [PATCH 10/15] Use correct path separator Signed-off-by: Y. Meyer-Norwood <106889957+norwd@users.noreply.github.com> --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 008829b..c460470 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -42,8 +42,8 @@ jobs: # yamlfmt configuration exclude-files: .github/testing/bad.yml include-files: | - **/*.{yaml,yml} - .github/testing/nonexisting.yml + **${{ contains(runner.temp, '\') && '\' || '/' }}*.{yaml,yml} + .github${{ contains(runner.temp, '\') && '\' || '/' }}testing${{ contains(runner.temp, '\') && '\' || '/' }}nonexisting.yml test_that_fmtya_should_report_missing_yamlfmt_version: if: always() From e9b42d0d869b0169eb56fee6cdb96de98267d4f2 Mon Sep 17 00:00:00 2001 From: "Y. Meyer-Norwood" <106889957+norwd@users.noreply.github.com> Date: Fri, 8 Nov 2024 08:54:34 +1300 Subject: [PATCH 11/15] Fix escape character Signed-off-by: Y. Meyer-Norwood <106889957+norwd@users.noreply.github.com> --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c460470..0bc2d2f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -40,10 +40,10 @@ jobs: signoff-on-commit: ${{ github.actor == github.repository_owner }} # yamlfmt configuration - exclude-files: .github/testing/bad.yml + exclude-files: .github${{ contains(runner.temp, '\') && '\\' || '/' }}testing${{ contains(runner.temp, '\') && '\\' || '/' }}bad.yml include-files: | - **${{ contains(runner.temp, '\') && '\' || '/' }}*.{yaml,yml} - .github${{ contains(runner.temp, '\') && '\' || '/' }}testing${{ contains(runner.temp, '\') && '\' || '/' }}nonexisting.yml + **${{ contains(runner.temp, '\') && '\\' || '/' }}*.{yaml,yml} + .github${{ contains(runner.temp, '\\') && '\' || '/' }}testing${{ contains(runner.temp, '\') && '\\' || '/' }}nonexisting.yml test_that_fmtya_should_report_missing_yamlfmt_version: if: always() From 3604cf45b616f73f47adc3e6e818ab050c7aeab9 Mon Sep 17 00:00:00 2001 From: "Y. Meyer-Norwood" <106889957+norwd@users.noreply.github.com> Date: Fri, 8 Nov 2024 09:08:36 +1300 Subject: [PATCH 12/15] Fix `\\` in the wrong place Signed-off-by: Y. Meyer-Norwood <106889957+norwd@users.noreply.github.com> --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0bc2d2f..0eb2235 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -43,7 +43,7 @@ jobs: exclude-files: .github${{ contains(runner.temp, '\') && '\\' || '/' }}testing${{ contains(runner.temp, '\') && '\\' || '/' }}bad.yml include-files: | **${{ contains(runner.temp, '\') && '\\' || '/' }}*.{yaml,yml} - .github${{ contains(runner.temp, '\\') && '\' || '/' }}testing${{ contains(runner.temp, '\') && '\\' || '/' }}nonexisting.yml + .github${{ contains(runner.temp, '\') && '\\' || '/' }}testing${{ contains(runner.temp, '\') && '\\' || '/' }}nonexisting.yml test_that_fmtya_should_report_missing_yamlfmt_version: if: always() From 6ebcb18e55247242dc61611450eaee08cf1b3b43 Mon Sep 17 00:00:00 2001 From: "Y. Meyer-Norwood" <106889957+norwd@users.noreply.github.com> Date: Fri, 8 Nov 2024 09:17:49 +1300 Subject: [PATCH 13/15] Don't use wildcards in windows, they don't seem to work Signed-off-by: Y. Meyer-Norwood <106889957+norwd@users.noreply.github.com> --- .github/workflows/test.yml | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0eb2235..9a6418d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -42,8 +42,21 @@ jobs: # yamlfmt configuration exclude-files: .github${{ contains(runner.temp, '\') && '\\' || '/' }}testing${{ contains(runner.temp, '\') && '\\' || '/' }}bad.yml include-files: | - **${{ contains(runner.temp, '\') && '\\' || '/' }}*.{yaml,yml} - .github${{ contains(runner.temp, '\') && '\\' || '/' }}testing${{ contains(runner.temp, '\') && '\\' || '/' }}nonexisting.yml + ${{ runner.os == 'Windows' && ' + action.yml + .github\release.yml + .github\labeler.yml + .github\dependabot.yml + .github\workflows\update-latest-tag.yml + .github\workflows\test.yml + .github\workflows\labeler.yml + .github\workflows\audit.yml + .github\testing\bad.yml + .github\testing\nonexisting.yml + ' || ' + **/*.{yaml,yml} + .github/testing/nonexisting.yml + ' }} test_that_fmtya_should_report_missing_yamlfmt_version: if: always() From e02a43f3356bb8cc2f3348c19eb269f8e1b1aad8 Mon Sep 17 00:00:00 2001 From: "Y. Meyer-Norwood" <106889957+norwd@users.noreply.github.com> Date: Fri, 8 Nov 2024 09:21:35 +1300 Subject: [PATCH 14/15] Update files lists in windows Signed-off-by: Y. Meyer-Norwood <106889957+norwd@users.noreply.github.com> --- .github/workflows/test.yml | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9a6418d..c795426 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -40,19 +40,24 @@ jobs: signoff-on-commit: ${{ github.actor == github.repository_owner }} # yamlfmt configuration - exclude-files: .github${{ contains(runner.temp, '\') && '\\' || '/' }}testing${{ contains(runner.temp, '\') && '\\' || '/' }}bad.yml + exclude-files: | + ${{ runner.os == 'Windows' && ' + .github\\testing\\bad.yml + ' || ' + .github\\testing\\bad.yml + ' }} + include-files: | ${{ runner.os == 'Windows' && ' action.yml - .github\release.yml - .github\labeler.yml - .github\dependabot.yml - .github\workflows\update-latest-tag.yml - .github\workflows\test.yml - .github\workflows\labeler.yml - .github\workflows\audit.yml - .github\testing\bad.yml - .github\testing\nonexisting.yml + .github\\release.yml + .github\\labeler.yml + .github\\dependabot.yml + .github\\workflows\\update-latest-tag.yml + .github\\workflows\\test.yml + .github\\workflows\\labeler.yml + .github\\workflows\\audit.yml + .github\\testing\\nonexisting.yml ' || ' **/*.{yaml,yml} .github/testing/nonexisting.yml From aae58d4be1079456e06eb4ffbb2c8e8b2b73df4d Mon Sep 17 00:00:00 2001 From: norwd Date: Thu, 7 Nov 2024 20:23:11 +0000 Subject: [PATCH 15/15] Auto yamlfmt Signed-off-by: norwd <106889957+norwd@users.noreply.github.com> --- .github/release.yml | 10 +++++----- action.yml | 3 +-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/release.yml b/.github/release.yml index 1505611..75571b3 100644 --- a/.github/release.yml +++ b/.github/release.yml @@ -16,18 +16,18 @@ changelog: categories: - - title: "\U0001F680 Features" + - title: "🚀 Features" labels: - 'feature' - 'enhancement' - - title: "\U0001F41B Bug Fixes" + - title: "🐛 Bug Fixes" labels: - 'fix' - 'bugfix' - 'bug' - - title: "\U0001F9F0 Maintenance" + - title: "🧰 Maintenance" labels: - 'chore' - 'github' @@ -37,13 +37,13 @@ changelog: - 'dependencies' - 'deps' - - title: "\U0001F4D6 Documentation" + - title: "📖 Documentation" labels: - 'documentation' - 'docs' - 'doc' - - title: "\U0001F6E1️ Security" + - title: "🛡️ Security" labels: - 'security' diff --git a/action.yml b/action.yml index b5d3430..2803054 100644 --- a/action.yml +++ b/action.yml @@ -206,5 +206,4 @@ runs: commit_user_email: ${{ inputs.commit-user-email }} commit_message: ${{ inputs.commit-message }} commit_options: >- - ${{ inputs.signing-private-key != '' && '-S' || '' }} - ${{ (inputs.signoff-on-commit == 'true' || inputs.signoff-on-commit == 'yes') && '-s' || '' }} + ${{ inputs.signing-private-key != '' && '-S' || '' }} ${{ (inputs.signoff-on-commit == 'true' || inputs.signoff-on-commit == 'yes') && '-s' || '' }}