Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create workflow to unit test fmtya #50

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
10 changes: 5 additions & 5 deletions .github/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -37,13 +37,13 @@ changelog:
- 'dependencies'
- 'deps'

- title: "\U0001F4D6 Documentation"
- title: "📖 Documentation"
labels:
- 'documentation'
- 'docs'
- 'doc'

- title: "\U0001F6E1️ Security"
- title: "🛡️ Security"
labels:
- 'security'

Expand Down
35 changes: 0 additions & 35 deletions .github/workflows/self-test.yml

This file was deleted.

92 changes: 92 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
---

name: "Run Tests"
run-name: "Run Tests"

on:
push:

jobs:

test_that_fmtya_can_run_on_itself:
if: always()
name: "Test that fmtya can run on itself"
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
max-parallel: 1
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: [email protected]
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: |
${{ 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\\nonexisting.yml
' || '
**/*.{yaml,yml}
.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:
fail-fast: false
max-parallel: 1
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
15 changes: 10 additions & 5 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ runs:
- name: "Configure yamlfmt"
shell: bash
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), '
- ') || '' }}
Expand All @@ -161,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/[email protected]
Expand All @@ -169,9 +171,11 @@ 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 }}
go-version: stable
cache: false

- name: "Install yamlfmt"
shell: bash
Expand All @@ -181,7 +185,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: ${{ format('{0}{1}yamlfmt.conf', runner.temp, contains(runner.temp, '\') && '\' || '/') }}

- name: "Setup GPG Keys"
if: inputs.signing-private-key != ''
Expand All @@ -200,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' || '' }}
Loading