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

build: adding YAML formatting check #30

Merged
merged 1 commit into from
Jan 31, 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
18 changes: 14 additions & 4 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,23 @@ env:
FORCE_COLOR: 1

jobs:
formatting:
name: Formatting
shell-formatting:
name: Shell Formatting
runs-on: ubuntu-latest
steps:
- name: Download Earthly v0.8.1.
run: "sudo /bin/sh -c 'wget https://github.com/earthly/earthly/releases/download/v0.8.1/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 --ci +check-formatting
- name: Check Shell formatting.
run: earthly --ci +check-shell-formatting
yaml-formatting:
name: YAML Formatting
runs-on: ubuntu-latest
steps:
- name: Download Earthly v0.8.1.
run: "sudo /bin/sh -c 'wget https://github.com/earthly/earthly/releases/download/v0.8.1/earthly-linux-amd64 -O /usr/local/bin/earthly && chmod +x /usr/local/bin/earthly'"
- name: Checkout code.
uses: actions/checkout@v3
- name: Check YAML formatting.
run: earthly --ci +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
39 changes: 33 additions & 6 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,50 @@ golang-base:
ENV GOARCH=amd64


formatting-base:
shell-formatting-base:
FROM +golang-base
RUN go install mvdan.cc/sh/v3/cmd/[email protected]
DO +COPY_CI_DATA


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


yaml-formatting-base:
FROM +golang-base
RUN go install github.com/google/yamlfmt/cmd/[email protected]
COPY ".yamlfmt" ".yamlfmt"
DO +COPY_CI_DATA

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


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


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


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


fix-formatting:
BUILD +fix-shell-formatting
BUILD +fix-yaml-formatting


check-conventional-commits-linting:
FROM +rust-base
RUN cargo install conventional_commits_linter --version 0.12.3
Expand Down
File renamed without changes.
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/**/* .goreleaser.yaml
File renamed without changes.
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/**/* .goreleaser.yaml
Loading