Skip to content

ci: adding GitHub Actions workflow formatting check #16

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

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/github-actions-workflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,13 @@ jobs:
uses: actions/checkout@v3
- name: Check GitHub Actions workflows linting.
run: earthly +check-github-actions-workflows-linting
formatting:
name: Formatting
runs-on: ubuntu-latest
steps:
- name: Download Earthly v0.8.6.
run: "sudo /bin/sh -c 'wget https://github.com/earthly/earthly/releases/download/v0.8.6/earthly-linux-amd64 -O /usr/local/bin/earthly && chmod +x /usr/local/bin/earthly'"
- name: Checkout code.
uses: actions/checkout@v3
- name: Check formatting.
run: earthly +check-yaml-formatting
3 changes: 3 additions & 0 deletions .yamlfmt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
formatter:
type: basic
retain_line_breaks: true
28 changes: 27 additions & 1 deletion Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,34 @@ check-conventional-commits-linting:
RUN ./ci/check-conventional-commits-linting.sh --from-reference "${from_reference}"


check-github-actions-workflows-linting:
golang-base:
FROM golang:1.20.13
ENV GOPROXY=direct
ENV CGO_ENABLED=0
ENV GOOS=linux
ENV GOARCH=amd64


yaml-formatting-base:
FROM +golang-base
RUN go install github.com/google/yamlfmt/cmd/yamlfmt@v0.10.0
COPY ".yamlfmt" "./"
DO +COPY_CI_DATA


check-yaml-formatting:
FROM +yaml-formatting-base
RUN ./ci/check-yaml-formatting.sh


fix-yaml-formatting:
FROM +yaml-formatting-base
RUN ./ci/fix-yaml-formatting.sh
SAVE ARTIFACT ".github/" AS LOCAL "./"


check-github-actions-workflows-linting:
FROM +golang-base
RUN go install github.com/rhysd/actionlint/cmd/actionlint@v1.6.26
DO +COPY_CI_DATA
RUN ./ci/check-github-actions-workflows-linting.sh
Expand Down
6 changes: 6 additions & 0 deletions ci/check-yaml-formatting.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

set -o errexit
set -o xtrace

yamlfmt -lint -dstar .github/**/*
6 changes: 6 additions & 0 deletions ci/fix-yaml-formatting.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env sh

set -o errexit
set -o xtrace

yamlfmt -dstar ./github/**/*
Loading