Skip to content

Commit 567a3d0

Browse files
authored
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 29ef6f1 commit 567a3d0

File tree

11 files changed

+57
-66
lines changed

11 files changed

+57
-66
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: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,27 @@
11
name: 'Publish Docs Site'
2-
32
on:
43
push:
54
branches:
65
- master
76
workflow_dispatch:
8-
97
permissions:
108
pages: 'write'
119
id-token: 'write'
12-
1310
jobs:
1411
build:
1512
name: "Build Docs"
1613
runs-on: 'ubuntu-latest'
1714
steps:
18-
- uses: 'actions/checkout@v4'
19-
- name: 'Generate HTML from Markdown'
20-
uses: 'ldeluigi/markdown-docs@latest'
21-
with:
22-
src: 'docs'
23-
dst: 'generated-pages'
24-
- name: 'Upload artifact'
25-
uses: 'actions/upload-pages-artifact@v3'
26-
with:
27-
path: 'generated-pages'
15+
- uses: 'actions/checkout@v4'
16+
- name: 'Generate HTML from Markdown'
17+
uses: 'ldeluigi/markdown-docs@latest'
18+
with:
19+
src: 'docs'
20+
dst: 'generated-pages'
21+
- name: 'Upload artifact'
22+
uses: 'actions/upload-pages-artifact@v3'
23+
with:
24+
path: 'generated-pages'
2825
deploy:
2926
name: "Deploy Docs"
3027
environment:
@@ -35,4 +32,4 @@ jobs:
3532
steps:
3633
- name: 'Deploy to GitHub Pages'
3734
id: 'deployment'
38-
uses: 'actions/deploy-pages@v4'
35+
uses: 'actions/deploy-pages@v4'
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/'

.github/workflows/publish_docs_preview_branch.yml

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,25 @@
11
name: 'Publish Preview of Docs Site from branch'
2-
3-
# The publish_docs_preview.yml workflow takes a PR and publishes the results to it's own branch
2+
# The publish_docs_preview.yml workflow takes a PR and publishes the results to it's own branch
43
# so users can preview it. But that git branch then needs some way to publish, so this action does that.
5-
6-
on:
4+
on:
75
push:
86
branch:
9-
- gh-pages
10-
7+
- gh-pages
118
permissions:
129
pages: 'write'
1310
id-token: 'write'
14-
15-
1611
jobs:
1712
stage:
1813
name: "Stage PR preview from branch to pages"
1914
runs-on: 'ubuntu-latest'
2015
steps:
21-
- uses: 'actions/checkout@v4'
22-
with:
23-
ref: 'refs/heads/gh-pages'
24-
- name: 'Upload artifact'
25-
uses: 'actions/upload-pages-artifact@v3'
26-
with:
27-
path: '.'
16+
- uses: 'actions/checkout@v4'
17+
with:
18+
ref: 'refs/heads/gh-pages'
19+
- name: 'Upload artifact'
20+
uses: 'actions/upload-pages-artifact@v3'
21+
with:
22+
path: '.'
2823
deploy:
2924
name: "Deploy PR Preview from branch to pages"
3025
needs: 'stage'
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 $*

0 commit comments

Comments
 (0)