Skip to content

Commit 25d1004

Browse files
committed
Create base template for Go projects
This adds all the base functionality that other Go projects within the Friendly FHIR organization use, so that this can be leveraged as a starting point for future projects.
1 parent 5f00809 commit 25d1004

18 files changed

+1047
-0
lines changed

.github/workflows/code-scanning.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
2+
name: Scheduled Code-Scanning
3+
4+
on:
5+
schedule:
6+
- cron: '0 0 * * *'
7+
8+
permissions:
9+
contents: read
10+
security-events: write
11+
actions: read
12+
13+
jobs:
14+
vulnerability-scanning:
15+
name: Vulnerability Scanning
16+
uses: friendly-fhir/.github/.github/workflows/go-vulnerability-scanning.yaml@master
17+
with:
18+
govulncheck-version: latest
19+
go-version-file: go.mod
20+
packages: ./...
21+
permissions:
22+
contents: read
23+
security-events: write
24+
25+
codeql-analysis:
26+
name: CodeQL Analysis
27+
uses: friendly-fhir/.github/.github/workflows/go-codeql.yaml@master
28+
with:
29+
go-version-file: go.mod
30+
permissions:
31+
contents: read
32+
security-events: write
33+
actions: read
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
2+
name: Greet new contributor
3+
4+
on:
5+
pull_request:
6+
types: [opened]
7+
issues:
8+
types: [opened]
9+
10+
permissions:
11+
contents: read
12+
issues: write
13+
pull-requests: write
14+
15+
jobs:
16+
greet:
17+
uses: friendly-fhir/.github/.github/workflows/community-greet-new-contributor.yaml@master
18+
permissions:
19+
contents: read
20+
issues: write
21+
pull-requests: write
22+
secrets: inherit
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
2+
name: Check for Stale Issues and Pull Requests
3+
4+
on:
5+
schedule:
6+
- cron: '0 0 * * *'
7+
8+
permissions:
9+
contents: read
10+
issues: write
11+
pull-requests: write
12+
13+
jobs:
14+
greet:
15+
uses: friendly-fhir/.github/.github/workflows/community-stale-check.yaml@master
16+
permissions:
17+
contents: read
18+
issues: write
19+
pull-requests: write
20+
secrets: inherit
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
2+
name: Deploy Github Pages
3+
on:
4+
push:
5+
branches: [master]
6+
7+
permissions:
8+
contents: read
9+
pages: write
10+
id-token: write
11+
12+
jobs:
13+
docs:
14+
name: Generate Documentation
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
20+
- name: Set up Python
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: "3.10"
24+
25+
- name: Install dependencies
26+
run: |
27+
pip install mkdocs
28+
pip install mkdocs-mermaid2-plugin
29+
pip install mkdocs-coverage
30+
31+
- name: Generate Documentation
32+
run: mkdocs build
33+
34+
# Some of the doc generation steps above create the directories with
35+
# 0750 for permissions -- which is triggering warning annotations in the
36+
# workflow summaries. Manually converting this to 0755 helps to suppress
37+
# this.
38+
- name: Fix permissions
39+
run: |
40+
find ./dist -type d -exec chmod 0755 {} \;
41+
find ./dist -type f -name '.lock' -delete
42+
43+
- name: Upload Pages Artifact
44+
uses: actions/upload-pages-artifact@v3
45+
with:
46+
path: dist/
47+
48+
deploy:
49+
name: Deploy to GH Pages
50+
runs-on: ubuntu-latest
51+
needs: docs
52+
53+
permissions:
54+
contents: read
55+
pages: write
56+
id-token: write
57+
58+
environment:
59+
name: github-pages
60+
url: ${{ steps.deployment.outputs.page_url }}
61+
62+
steps:
63+
- name: Upload GH Pages
64+
id: deployment
65+
uses: actions/deploy-pages@v4

.github/workflows/postsubmit.yaml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
2+
name: Postsubmit
3+
4+
on:
5+
workflow_call:
6+
push:
7+
branches:
8+
- master
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref_name }}
12+
cancel-in-progress: true
13+
14+
permissions:
15+
contents: read
16+
security-events: write
17+
id-token: write
18+
actions: read
19+
20+
jobs:
21+
build-and-test:
22+
name: Build and Test
23+
uses: friendly-fhir/.github/.github/workflows/go-build-and-test.yaml@master
24+
with:
25+
packages: ./...
26+
go-version-file: go.mod
27+
short-test: false
28+
permissions:
29+
contents: read
30+
id-token: write
31+
32+
snapshot-release:
33+
name: Snapshot Release
34+
uses: friendly-fhir/.github/.github/workflows/go-release.yaml@master
35+
with:
36+
snapshot: true
37+
permissions:
38+
contents: write
39+
attestations: write
40+
id-token: write
41+
42+
email-on-failure:
43+
name: Email on Failure
44+
runs-on: ubuntu-latest
45+
needs:
46+
- build-and-test
47+
- snapshot-release
48+
if: always() && failure()
49+
continue-on-error: true
50+
steps:
51+
- name: Send email
52+
uses: friendly-fhir/.github/actions/community/send-email@master
53+
with:
54+
recipient: [email protected]
55+
api-key: ${{ secrets.MAILGUN_API_KEY }}
56+
subject: ${{ github.repository}} Post-submit failed
57+
body: |
58+
The post-submit workflow for ${{ github.repository }} failed.
59+
Please see ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} for details.

.github/workflows/presubmit.yaml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
2+
name: Presubmit
3+
4+
on:
5+
workflow_call:
6+
pull_request:
7+
branches:
8+
- master
9+
10+
permissions:
11+
contents: read
12+
security-events: write
13+
id-token: write
14+
actions: read
15+
16+
jobs:
17+
build-and-test:
18+
name: Build and Test
19+
uses: friendly-fhir/.github/.github/workflows/go-build-and-test.yaml@master
20+
with:
21+
packages: ./...
22+
go-version-file: go.mod
23+
short-test: true
24+
permissions:
25+
contents: read
26+
id-token: write
27+
28+
license-manifest:
29+
name: License Manifest
30+
uses: friendly-fhir/.github/.github/workflows/go-license.yaml@master
31+
with:
32+
go-version-file: go.mod
33+
packages: ./...
34+
artifact-name: license-report
35+
go-licenses-version: latest
36+
license-file-name: license-report.csv
37+
permissions:
38+
contents: read
39+
40+
vulnerability-scanning:
41+
name: Vulnerability Scanning
42+
uses: friendly-fhir/.github/.github/workflows/go-vulnerability-scanning.yaml@master
43+
with:
44+
go-version-file: go.mod
45+
packages: ./...
46+
govulncheck-version: latest
47+
permissions:
48+
contents: read
49+
security-events: write
50+
51+
go-lint:
52+
name: Go Lint
53+
uses: friendly-fhir/.github/.github/workflows/go-lint.yaml@master
54+
with:
55+
go-version-file: go.mod
56+
permissions:
57+
contents: read
58+
59+
markdown-lint:
60+
name: Markdown Lint
61+
uses: friendly-fhir/.github/.github/workflows/markdown-lint.yaml@master
62+
with:
63+
config: .markdownlint.jsonc
64+
globs: |
65+
README.md
66+
docs/**/*.md
67+
.github/**/*.md
68+
permissions:
69+
contents: read
70+
71+
# This check is a no-op that exists so that GitHub has a check to mark as
72+
# required and successful.
73+
check-success:
74+
name: Check Success
75+
runs-on: ubuntu-latest
76+
if: github.event_name == 'pull_request'
77+
needs:
78+
- build-and-test
79+
- license-manifest
80+
- vulnerability-scanning
81+
- go-lint
82+
- markdown-lint
83+
steps:
84+
- name: Success
85+
run: echo "All checks passed"
86+
shell: bash
87+
permissions:
88+
contents: read

.github/workflows/promote-branch.yaml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
2+
name: Promote Branch
3+
4+
on:
5+
push:
6+
branches:
7+
- develop
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref_name }}
11+
cancel-in-progress: true
12+
13+
permissions:
14+
contents: write
15+
security-events: write
16+
id-token: write
17+
actions: read
18+
19+
jobs:
20+
presubmit:
21+
name: Presubmit
22+
uses: ./.github/workflows/presubmit.yaml
23+
permissions:
24+
contents: read
25+
id-token: write
26+
security-events: write
27+
actions: read
28+
secrets: inherit
29+
30+
promote:
31+
name: Promote to Master
32+
needs: presubmit
33+
uses: friendly-fhir/.github/.github/workflows/promote-branch.yaml@master
34+
with:
35+
branch: master
36+
secrets: inherit
37+
permissions:
38+
contents: write
39+
id-token: write

.github/workflows/release.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
2+
name: Release
3+
4+
on:
5+
push:
6+
tags:
7+
- "v*"
8+
9+
permissions:
10+
contents: write
11+
security-events: write
12+
id-token: write
13+
actions: read
14+
15+
jobs:
16+
continuous-integration:
17+
name: Continuous Integration
18+
uses: ./.github/workflows/presubmit.yaml
19+
permissions:
20+
contents: read
21+
security-events: write
22+
id-token: write
23+
actions: read
24+
25+
release:
26+
name: Release
27+
needs: continuous-integration
28+
uses: friendly-fhir/.github/.github/workflows/go-release.yaml@master
29+
with:
30+
snapshot: false
31+
permissions:
32+
contents: write
33+
attestations: write
34+
id-token: write

.golanglint.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# yaml-language-server: $schema=https://golangci-lint.run/jsonschema/golangci.jsonschema.json
2+
3+
linters:
4+
enable-all: true

0 commit comments

Comments
 (0)