Skip to content

Commit

Permalink
build: check yaml and json formatting with dprint (#1047)
Browse files Browse the repository at this point in the history
Signed-off-by: Charlie Egan <[email protected]>
  • Loading branch information
charlieegan3 authored Sep 4, 2024
1 parent ccb66fc commit fe9e0d9
Show file tree
Hide file tree
Showing 12 changed files with 94 additions and 82 deletions.
54 changes: 27 additions & 27 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ jobs:
strategy:
matrix:
os:
- runner: ubuntu-latest
name: linux
static: true
- runner: macos-13
name: macos-intel
static: false
- runner: macos-14
name: macos-arm64
static: true
- runner: ubuntu-latest
name: linux
static: true
- runner: macos-13
name: macos-intel
static: false
- runner: macos-14
name: macos-arm64
static: true
runs-on: ${{ matrix.os.runner }}
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
Expand All @@ -40,7 +40,7 @@ jobs:
with:
version: v0.68.0
static: ${{ matrix.os.static }}
- run: npm install -g markdownlint-cli
- run: npm install -g markdownlint-cli dprint
- name: Restore rq cache
id: cache-rq
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
Expand Down Expand Up @@ -68,20 +68,20 @@ jobs:
code_coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
with:
go-version-file: go.mod
- uses: open-policy-agent/setup-opa@34a30e8a924d1b03ce2cf7abe97250bbb1f332b5 # v2.2.0
with:
version: v0.68.0
- run: |
go run main.go test --coverage bundle \
| opa eval -f raw -I -d build/simplecov/simplecov.rego data.build.simplecov.from_opa \
> coverage.json
- uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0
with:
fail_ci_if_error: false
files: ./coverage.json
name: regal
token: ${{ secrets.CODECOV_TOKEN }} # required
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
with:
go-version-file: go.mod
- uses: open-policy-agent/setup-opa@34a30e8a924d1b03ce2cf7abe97250bbb1f332b5 # v2.2.0
with:
version: v0.68.0
- run: |
go run main.go test --coverage bundle \
| opa eval -f raw -I -d build/simplecov/simplecov.rego data.build.simplecov.from_opa \
> coverage.json
- uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0
with:
fail_ci_if_error: false
files: ./coverage.json
name: regal
token: ${{ secrets.CODECOV_TOKEN }} # required
28 changes: 14 additions & 14 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: "CodeQL"

on:
schedule:
- cron: '19 18 * * 4'
- cron: "19 18 * * 4"

permissions:
contents: read
Expand All @@ -20,21 +20,21 @@ jobs:
strategy:
fail-fast: false
matrix:
language: [ 'go' ]
language: ["go"]

steps:
- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Initialize CodeQL
uses: github/codeql-action/init@4dd16135b69a43b6c8efb853346f8437d92d3c93 # v3.26.6
with:
languages: ${{ matrix.language }}
- name: Initialize CodeQL
uses: github/codeql-action/init@4dd16135b69a43b6c8efb853346f8437d92d3c93 # v3.26.6
with:
languages: ${{ matrix.language }}

- name: Autobuild
uses: github/codeql-action/autobuild@4dd16135b69a43b6c8efb853346f8437d92d3c93 # v3.26.6
- name: Autobuild
uses: github/codeql-action/autobuild@4dd16135b69a43b6c8efb853346f8437d92d3c93 # v3.26.6

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@4dd16135b69a43b6c8efb853346f8437d92d3c93 # v3.26.6
with:
category: "/language:${{matrix.language}}"
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@4dd16135b69a43b6c8efb853346f8437d92d3c93 # v3.26.6
with:
category: "/language:${{matrix.language}}"
4 changes: 2 additions & 2 deletions .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Scorecard supply-chain security
on:
branch_protection_rule:
schedule:
- cron: '16 9 * * 2'
- cron: "16 9 * * 2"
push:
branches: [ "main" ]
branches: ["main"]

permissions: read-all

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ name: Update Docs
on:
push:
tags:
- v[0-9].**
- v[0-9].**
workflow_dispatch:

permissions: read-all
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-example-index.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ name: Update Examples Index
on:
workflow_dispatch:
schedule:
- cron: '0 1 * * *' # Run daily at 1 AM UTC
- cron: "0 1 * * *" # Run daily at 1 AM UTC

jobs:
update-examples-index:
Expand Down
4 changes: 2 additions & 2 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ kos:
build: linux-windows-build
repository: ghcr.io/styrainc/regal
tags:
- '{{.Version}}'
- "{{.Version}}"
- latest
bare: true
base_image: cgr.dev/chainguard/busybox:latest-glibc
Expand All @@ -65,7 +65,7 @@ archives:
{{- if .Arm }}v{{ .Arm }}{{ end }}
checksum:
name_template: 'checksums.txt'
name_template: "checksums.txt"

snapshot:
name_template: "{{ incpatch .Version }}-next"
Expand Down
16 changes: 8 additions & 8 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"opa.env": {
"OPA_CHECK_CAPABILITIES": "${workspacePath}/build/capabilities.json",
"OPA_EVAL_CAPABILITIES": "${workspacePath}/build/capabilities.json"
},
"opa.roots": [
"${workspaceFolder}/bundle"
],
"opa.strictMode": true
"opa.env": {
"OPA_CHECK_CAPABILITIES": "${workspacePath}/build/capabilities.json",
"OPA_EVAL_CAPABILITIES": "${workspacePath}/build/capabilities.json"
},
"opa.roots": [
"${workspaceFolder}/bundle"
],
"opa.strictMode": true
}
50 changes: 25 additions & 25 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "regal: prepare pr",
"type": "shell",
"command": "./build/do.rq pr",
"detail": "Prepare PR",
"options": {
"cwd": "${workspaceFolder}"
},
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "regal: regal test",
"type": "shell",
"command": "go run main.go test bundle",
"group": "test",
"options": {
"cwd": "${workspaceFolder}"
}
}
]
"version": "2.0.0",
"tasks": [
{
"label": "regal: prepare pr",
"type": "shell",
"command": "./build/do.rq pr",
"detail": "Prepare PR",
"options": {
"cwd": "${workspaceFolder}"
},
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "regal: regal test",
"type": "shell",
"command": "go run main.go test bundle",
"group": "test",
"options": {
"cwd": "${workspaceFolder}"
}
}
]
}
1 change: 1 addition & 0 deletions build/do.rq
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ lint_ci {
run("opa check --strict --capabilities build/capabilities.json bundle")
run_quiet("./regal lint --format github bundle")
run("markdownlint --config docs/.markdownlint.yaml --ignore docs/CODE_OF_CONDUCT.md README.md docs/")
run("dprint --config build/dprint.json check")
}

check_readme {
Expand Down
11 changes: 11 additions & 0 deletions build/dprint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"yaml": {
"indentBlockSequenceInMap": true
},
"json": {},
"excludes": [],
"plugins": [
"https://plugins.dprint.dev/g-plane/pretty_yaml-v0.5.0.wasm",
"https://plugins.dprint.dev/json-0.19.3.wasm"
]
}
2 changes: 1 addition & 1 deletion bundle/regal/config/provided/data.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ rules:
annotation-without-metadata:
level: error
argument-always-wildcard:
except-function-name-pattern: '^mock_'
except-function-name-pattern: "^mock_"
level: error
constant-condition:
level: error
Expand Down
2 changes: 1 addition & 1 deletion e2e/testdata/configs/custom_naming_convention.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ rules:
naming-convention:
level: error
conventions:
- pattern: '^_[a-z_]+$|^allow$'
- pattern: "^_[a-z_]+$|^allow$"
targets:
- rule
- pattern: '^acmecorp\.[a-z_\.]+$'
Expand Down

0 comments on commit fe9e0d9

Please sign in to comment.