Skip to content

Commit

Permalink
ci: add linting for yml files (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
dhth authored Sep 11, 2024
1 parent 9c638be commit b84edcf
Show file tree
Hide file tree
Showing 9 changed files with 163 additions and 125 deletions.
56 changes: 28 additions & 28 deletions .github/workflows/back-compat-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,31 +21,31 @@ jobs:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- uses: actions/checkout@v4
with:
ref: main
- name: build main
run: |
go build -o hours_main
cp hours_main /var/tmp
rm hours_main
- uses: actions/checkout@v4
- name: build head
run: |
go build -o hours_head
cp hours_head /var/tmp
rm hours_head
- name: Run last version
run: |
/var/tmp/hours_main --dbpath=/var/tmp/throwaway-1.db report 3d -p
/var/tmp/hours_main --dbpath=/var/tmp/throwaway-2.db gen -y
- name: Run current version
run: |
/var/tmp/hours_head --dbpath=/var/tmp/throwaway-1.db report 3d -p
/var/tmp/hours_head --dbpath=/var/tmp/throwaway-2.db report 3d -p
/var/tmp/hours_head --dbpath=/var/tmp/throwaway-2.db log 3d -p
/var/tmp/hours_head --dbpath=/var/tmp/throwaway-2.db stats 3d -p
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- uses: actions/checkout@v4
with:
ref: main
- name: build main
run: |
go build -o hours_main
cp hours_main /var/tmp
rm hours_main
- uses: actions/checkout@v4
- name: build head
run: |
go build -o hours_head
cp hours_head /var/tmp
rm hours_head
- name: Run last version
run: |
/var/tmp/hours_main --dbpath=/var/tmp/throwaway-1.db report 3d -p
/var/tmp/hours_main --dbpath=/var/tmp/throwaway-2.db gen -y
- name: Run current version
run: |
/var/tmp/hours_head --dbpath=/var/tmp/throwaway-1.db report 3d -p
/var/tmp/hours_head --dbpath=/var/tmp/throwaway-2.db report 3d -p
/var/tmp/hours_head --dbpath=/var/tmp/throwaway-2.db log 3d -p
/var/tmp/hours_head --dbpath=/var/tmp/throwaway-2.db stats 3d -p
60 changes: 30 additions & 30 deletions .github/workflows/back-compat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: back-compat

on:
push:
branches: [ "main" ]
branches: ["main"]

permissions:
contents: read
Expand All @@ -18,32 +18,32 @@ jobs:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- uses: actions/checkout@v4
with:
fetch-depth: 2
- run: git checkout HEAD~1
- name: build last commit
run: |
go build -o hours_prev
cp hours_prev /var/tmp
rm hours_prev
- run: git checkout main
- name: build head
run: |
go build -o hours_head
cp hours_head /var/tmp
rm hours_head
- name: Run last version
run: |
/var/tmp/hours_prev --dbpath=/var/tmp/throwaway-1.db report 3d -p
/var/tmp/hours_prev --dbpath=/var/tmp/throwaway-2.db gen -y
- name: Run current version
run: |
/var/tmp/hours_head --dbpath=/var/tmp/throwaway-1.db report 3d -p
/var/tmp/hours_head --dbpath=/var/tmp/throwaway-2.db report 3d -p
/var/tmp/hours_head --dbpath=/var/tmp/throwaway-2.db log 3d -p
/var/tmp/hours_head --dbpath=/var/tmp/throwaway-2.db stats 3d -p
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- uses: actions/checkout@v4
with:
fetch-depth: 2
- run: git checkout HEAD~1
- name: build last commit
run: |
go build -o hours_prev
cp hours_prev /var/tmp
rm hours_prev
- run: git checkout main
- name: build head
run: |
go build -o hours_head
cp hours_head /var/tmp
rm hours_head
- name: Run last version
run: |
/var/tmp/hours_prev --dbpath=/var/tmp/throwaway-1.db report 3d -p
/var/tmp/hours_prev --dbpath=/var/tmp/throwaway-2.db gen -y
- name: Run current version
run: |
/var/tmp/hours_head --dbpath=/var/tmp/throwaway-1.db report 3d -p
/var/tmp/hours_head --dbpath=/var/tmp/throwaway-2.db report 3d -p
/var/tmp/hours_head --dbpath=/var/tmp/throwaway-2.db log 3d -p
/var/tmp/hours_head --dbpath=/var/tmp/throwaway-2.db stats 3d -p
36 changes: 18 additions & 18 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: build

on:
push:
branches: [ "main" ]
branches: ["main"]
pull_request:
paths:
- "go.*"
Expand All @@ -23,20 +23,20 @@ jobs:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: go build
run: go build -v ./...
- name: go test
run: go test -v ./...
- name: run hours
run: |
go build .
./hours --dbpath=/var/tmp/throwaway-1.db report 3d -p
./hours --dbpath=/var/tmp/throwaway-2.db gen -y
./hours --dbpath=/var/tmp/throwaway-2.db report 3d -p
./hours --dbpath=/var/tmp/throwaway-2.db log 3d -p
./hours --dbpath=/var/tmp/throwaway-2.db stats 3d -p
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: go build
run: go build -v ./...
- name: go test
run: go test -v ./...
- name: run hours
run: |
go build .
./hours --dbpath=/var/tmp/throwaway-1.db report 3d -p
./hours --dbpath=/var/tmp/throwaway-2.db gen -y
./hours --dbpath=/var/tmp/throwaway-2.db report 3d -p
./hours --dbpath=/var/tmp/throwaway-2.db log 3d -p
./hours --dbpath=/var/tmp/throwaway-2.db stats 3d -p
36 changes: 36 additions & 0 deletions .github/workflows/lint-yml.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: lint-yml

on:
push:
branches: ["main"]
paths:
- "**.yml"
pull_request:
paths:
- "**.yml"

env:
GO_VERSION: '1.23.0'

jobs:
lint-yml:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: changes
with:
filters: |
yml:
- added|modified: '**.yml'
- name: Set up Go
if: steps.changes.outputs.yml == 'true'
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Get yamlfmt
if: steps.changes.outputs.yml == 'true'
run: go install github.com/google/yamlfmt/cmd/yamlfmt@latest
- name: Run yamlfmt
if: steps.changes.outputs.yml == 'true'
run: yamlfmt -lint -quiet $(find . -name '*.yml')
20 changes: 10 additions & 10 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: lint

on:
push:
branches: [ "main" ]
branches: ["main"]
pull_request:
paths:
- "go.*"
Expand All @@ -20,12 +20,12 @@ jobs:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.60
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.60
56 changes: 28 additions & 28 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,31 @@ jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Build
run: go build -v ./...
- name: Test
run: go test -v ./...
- name: Install Cosign
uses: sigstore/cosign-installer@v3
with:
cosign-release: 'v2.2.3'
- name: Store Cosign private key in a file
run: 'echo "$COSIGN_KEY" > cosign.key'
shell: bash
env:
COSIGN_KEY: ${{secrets.COSIGN_KEY}}
- name: Release Binaries
uses: goreleaser/goreleaser-action@v6
with:
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{secrets.GH_PAT}}
COSIGN_PASSWORD: ${{secrets.COSIGN_PASSWORD}}
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Build
run: go build -v ./...
- name: Test
run: go test -v ./...
- name: Install Cosign
uses: sigstore/cosign-installer@v3
with:
cosign-release: 'v2.2.3'
- name: Store Cosign private key in a file
run: 'echo "$COSIGN_KEY" > cosign.key'
shell: bash
env:
COSIGN_KEY: ${{secrets.COSIGN_KEY}}
- name: Release Binaries
uses: goreleaser/goreleaser-action@v6
with:
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{secrets.GH_PAT}}
COSIGN_PASSWORD: ${{secrets.COSIGN_PASSWORD}}
22 changes: 11 additions & 11 deletions .github/workflows/vulncheck.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: vulncheck
on:
push:
branches: [ "main" ]
branches: ["main"]
pull_request:
paths:
- "go.*"
Expand All @@ -19,13 +19,13 @@ jobs:
name: vulncheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: govulncheck
shell: bash
run: |
go install golang.org/x/vuln/cmd/govulncheck@latest
govulncheck ./...
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: govulncheck
shell: bash
run: |
go install golang.org/x/vuln/cmd/govulncheck@latest
govulncheck ./...
File renamed without changes.
2 changes: 2 additions & 0 deletions yamlfmt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
formatter:
retain_line_breaks_single: true

0 comments on commit b84edcf

Please sign in to comment.