Skip to content

Commit 241026d

Browse files
committed
Add some more lint/format checks. (#21)
* Add some more lint/format checks. * Add yamlfmt as a required check * Make it easier for people to run the checks locally * yamlfmt all files. * Fix workflow to be correct path.
1 parent e181577 commit 241026d

File tree

10 files changed

+37
-41
lines changed

10 files changed

+37
-41
lines changed

.github/workflows/action_scanning.yml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,36 @@
11
### Required actions to scan GitHub action workflows for security issues.
22
name: 'Scan GitHub Action workflows files for security issues'
3-
43
on:
54
pull_request: {}
6-
75
permissions:
86
contents: 'read'
97
security-events: 'write'
108
actions: 'read'
11-
129
jobs:
1310
semgrep:
1411
name: 'semgrep-oss/scan'
1512
runs-on: 'ubuntu-latest'
16-
1713
container:
1814
image: 'index.docker.io/semgrep/semgrep@sha256:85782eaf09692e6dfb684cd3bad87ef315775814b01f76b4d15582e4ca7c1c89' # ratchet:semgrep/semgrep
19-
2015
# Skip any PR created by dependabot to avoid permission issues:
2116
if: (github.actor != 'dependabot[bot]')
22-
2317
steps:
2418
- name: 'Checkout Code'
2519
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # ratchet:actions/checkout@v4
26-
2720
- name: 'Checkout Workflow Config'
2821
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # ratchet:actions/checkout@v4
2922
env:
3023
GH_REPO_OWNER: ${{ github.repository_owner }}
3124
with:
3225
repository: 'google/github-team'
3326
path: action_scanning
34-
3527
- name: 'Run Actions semgrep scan'
3628
run: 'semgrep scan --sarif --config action_scanning/semgrep-rules/actions >> semgrep-results-actions.sarif'
37-
3829
- name: 'Save Actions SARIF results as artifact'
3930
uses: 'actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02' # ratchet:actions/upload-artifact@v4
4031
with:
4132
name: 'semgrep-scan-results-actions'
4233
path: 'semgrep-results-actions.sarif'
43-
4434
- name: 'Upload Actions SARIF result to the GitHub Security Dashboard'
4535
uses: 'github/codeql-action/upload-sarif@1b549b9259bda1cb5ddde3b41741a82a2d15a841' # ratchet:github/codeql-action/upload-sarif@v3
4636
with:
Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
### Ensure that markdown files are properly formatted
22
name: 'Check Markdown Format'
3-
43
on:
5-
pull_request:
4+
pull_request:
65
paths:
76
- '**.md'
8-
97
jobs:
108
mdformat:
119
name: 'mdformat'
1210
runs-on: 'ubuntu-latest'
13-
1411
steps:
1512
- name: 'Checkout Code'
1613
uses: 'actions/checkout@v4'
17-
1814
- name: 'Check Markdown Format'
19-
run: 'pipx run mdformat --check --wrap 100 .'
15+
run: 'tools/mdformat --check --wrap 100 .'

.github/workflows/publish_docs.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
name: 'Publish Docs Site'
2-
32
on:
43
push:
54
branches:
@@ -8,11 +7,9 @@ on:
87
- '**.md'
98
- '.github/workflow/publish*'
109
workflow_dispatch:
11-
1210
permissions:
1311
pages: 'write'
1412
id-token: 'write'
15-
1613
jobs:
1714
build-and-deploy:
1815
name: "Build and Deploy Docs"
@@ -31,4 +28,4 @@ jobs:
3128
with:
3229
folder: generated-pages
3330
force: false
34-
clean-exclude: pr-preview/
31+
clean-exclude: pr-preview/
Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,26 @@
11
name: 'Publish Preview of Docs Site'
2-
32
on:
43
pull_request:
54
types:
65
- opened
76
- reopened
87
- synchronize
98
- closed
10-
119
permissions:
1210
contents: 'write'
1311
pull-requests: 'write'
14-
1512
jobs:
1613
build:
1714
name: "Build PR Preview Docs"
1815
runs-on: 'ubuntu-latest'
1916
steps:
20-
- uses: 'actions/checkout@v4'
21-
- name: 'Generate HTML from Markdown'
22-
uses: 'ldeluigi/markdown-docs@latest'
23-
with:
24-
src: 'docs'
25-
dst: 'generated-pages'
26-
- name: 'Deploy GitHub Pages Preview'
27-
uses: rossjrw/pr-preview-action@v1
28-
with:
29-
source-dir: './generated-pages/'
17+
- uses: 'actions/checkout@v4'
18+
- name: 'Generate HTML from Markdown'
19+
uses: 'ldeluigi/markdown-docs@latest'
20+
with:
21+
src: 'docs'
22+
dst: 'generated-pages'
23+
- name: 'Deploy GitHub Pages Preview'
24+
uses: rossjrw/pr-preview-action@v1
25+
with:
26+
source-dir: './generated-pages/'
Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,20 @@
11
### Ensure that our local testing always passes
22
name: 'Run semgrep tests'
3-
43
on:
54
pull_request: {}
6-
75
permissions:
86
contents: 'read'
97
actions: 'read'
10-
118
jobs:
129
semgrep-tests:
1310
name: 'Run semgrep tests'
1411
runs-on: 'ubuntu-latest'
15-
1612
container:
1713
image: index.docker.io/semgrep/semgrep@sha256:85782eaf09692e6dfb684cd3bad87ef315775814b01f76b4d15582e4ca7c1c89 # ratchet:semgrep/semgrep
18-
1914
# Skip any PR created by dependabot to avoid permission issues:
2015
if: (github.actor != 'dependabot[bot]')
21-
2216
steps:
2317
- name: 'Checkout Code'
2418
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # ratchet:actions/checkout@v4
25-
2619
- name: 'Run Actions semgrep scan'
2720
run: 'semgrep --test --config semgrep-rules semgrep-tests'

.github/workflows/yaml_format.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
### Ensure that Yaml files are properly formatted
2+
name: 'Check Yaml Format'
3+
on:
4+
pull_request:
5+
paths:
6+
- '**.yml'
7+
- '**.yaml'
8+
jobs:
9+
yamlfmt:
10+
name: 'yamlfmt'
11+
runs-on: 'ubuntu-latest'
12+
steps:
13+
- name: 'Checkout Code'
14+
uses: 'actions/checkout@v4'
15+
- name: 'Check Yaml Format'
16+
run: 'tools/yamlfmt --lint .'

.yamlfmt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
formatter:
2+
max_line_length: 100
3+
trim_trailing_whitespace: true
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
on:
22
# ruleid: pull-request-target-needs-exception
3-
pull_request_target:
3+
pull_request_target:

tools/mdformat

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
pipx run mdformat $*

tools/yamlfmt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
docker run -v "$(pwd):/project" ghcr.io/google/yamlfmt:latest $*

0 commit comments

Comments
 (0)