Skip to content

Commit 025a45f

Browse files
bitwizeshiftCopybara
and
Copybara
authored
Initial project import (#1)
This performs the initial project import of the `fsh-lint` project using the [`copybara`] tool. Content has been reviewed for IP content by: * [x] @bitwizeshift (myself), and * [x] @joelphillip1 [copybara]: https://github.com/google/copybara GitOrigin-RevId: 2735270525e429aa4b425e9b3f60971355a53382 Co-authored-by: Copybara <copybara@example.com>
1 parent 696c6f7 commit 025a45f

File tree

92 files changed

+33173
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+33173
-2
lines changed

.github/CODEOWNERS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Note: For syntax, see <https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners#codeowners-syntax>
2+
3+
* @verily-src/fsh-lint-eng-reviewers

.github/workflows/ci.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: CI
2+
on:
3+
pull_request:
4+
branches:
5+
- main
6+
7+
jobs:
8+
build-test:
9+
name: Build and Test
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v4
14+
15+
- name: Setup Go
16+
uses: actions/setup-go@v5
17+
with:
18+
go-version-file: go.mod
19+
20+
- name: Tidy
21+
run: |
22+
go mod tidy
23+
git diff --exit-code
24+
25+
- name: Vet
26+
run: go vet -v -unreachable=false ./...
27+
28+
- name: Build
29+
run: go build -v ./...
30+
31+
- name: Test
32+
run: go test -v ./...

.github/workflows/contribution.yaml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Schema: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions
2+
name: Verify Contribution Guidelines
3+
4+
on:
5+
pull_request:
6+
branches:
7+
- main
8+
types:
9+
- opened
10+
- reopened
11+
- edited
12+
- synchronize
13+
14+
env:
15+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}∂
16+
MESSAGE: >
17+
Thank you for your interest in this project! At this moment, we are not
18+
currently accepting community contributions in the form of PRs.
19+
If you would like to make a proposal,
20+
we will do our best to review it, implement it ourselves, and include it in
21+
the next release. If enough proposals come through, we will certainly revisit
22+
this policy to make the package as useful as possible.
23+
24+
[Contribution Guidelines](https://github.com/verily-src/fsh-lint/CONTRIBUTING.md).
25+
26+
Thank you! 🙂
27+
28+
jobs:
29+
pr-description:
30+
name: Check PR Description
31+
runs-on: ubuntu-latest
32+
if: ${{ !contains(fromJSON('["bitwizeshift","biki23","samanvp"]'),github.event.pull_request.user.login) }}
33+
steps:
34+
- name: Check for existing comment
35+
id: comment
36+
continue-on-error: true
37+
env:
38+
PR_NUM: ${{ github.event.pull_request.number }}
39+
run: |
40+
# Check if comment already exists
41+
comment_id=$(gh api \
42+
-H "Accept: application/vnd.github+json" \
43+
-H "X-GitHub-Api-Version: 2022-11-28" \
44+
"repos/verily-src/verily1/issues/${{ env.PR_NUM }}/comments" \
45+
--jq ".[] | select(.body | contains(\"${{ env.MESSAGE }}\")) | .id")
46+
47+
echo "id=${comment_id}" >> "${GITHUB_OUTPUT}"
48+
49+
- name: Post comment
50+
env:
51+
PR_NUM: ${{ github.event.pull_request.number }}
52+
PR_URL: ${{ github.event.pull_request.html_url }}
53+
AUTHOR: "@${{ github.event.pull_request.user.login }}"
54+
if: steps.comment.outputs.id == ''
55+
continue-on-error: true
56+
run: |
57+
gh pr comment "${{ env.PR_URL }}" -b "${{ env.AUTHOR }} ${{ env.MESSAGE }}"

.github/workflows/release.yaml

Lines changed: 278 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,278 @@
1+
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
2+
name: Release
3+
4+
on:
5+
push:
6+
branches:
7+
- main
8+
tags:
9+
- v*
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref_name }}
13+
cancel-in-progress: true
14+
15+
permissions:
16+
# Required to write the release artifacts
17+
contents: write
18+
19+
# Required for producing attestation statements
20+
attestations: write
21+
22+
# Required for writing GHCR images
23+
packages: write
24+
25+
# Required for modifying the token
26+
id-token: write
27+
28+
jobs:
29+
release-binaries:
30+
name: Release ${{ github.ref_name }} Binaries
31+
runs-on: ubuntu-latest
32+
permissions:
33+
contents: write
34+
outputs:
35+
jobs: ${{ steps.create-jobs.outputs.jobs }}
36+
project-name: ${{ steps.metadata.outputs.project-name }}
37+
artifact-id: ${{ steps.release-artifact.outputs.artifact-id }}
38+
artifact-url: ${{ steps.release-artifact.outputs.artifact-url }}
39+
artifact-name: release-assets
40+
steps:
41+
- name: Checkout
42+
uses: actions/checkout@v4
43+
with:
44+
fetch-depth: 0
45+
46+
- name: Set up Go
47+
uses: actions/setup-go@v5
48+
with:
49+
go-version-file: go.mod
50+
51+
- name: Setup CyloneDX-Gomod
52+
run: |
53+
go install github.com/CycloneDX/cyclonedx-gomod/cmd/cyclonedx-gomod@latest
54+
55+
- name: Create Release
56+
if: github.event_name == 'push' && github.ref_name != 'main'
57+
uses: goreleaser/goreleaser-action@v5
58+
with:
59+
distribution: goreleaser
60+
version: "~> v1"
61+
args: release --clean
62+
env:
63+
GITHUB_TOKEN: ${{ github.token }}
64+
65+
- name: Create Snapshot Release
66+
if: github.event_name == 'push' && github.ref_name == 'main'
67+
uses: goreleaser/goreleaser-action@v5
68+
with:
69+
distribution: goreleaser
70+
version: "~> v1"
71+
args: release --clean --snapshot
72+
env:
73+
GITHUB_TOKEN: ${{ github.token }}
74+
75+
- name: Read metadata
76+
id: metadata
77+
run: |
78+
dist=$(yq '.dist // "dist"' .goreleaser.yaml)
79+
dist=$(cd ${dist}; pwd)
80+
sbom_configured=$(yq e '. | has("sboms")' .goreleaser.yaml)
81+
project_name=$(cat "${dist}/metadata.json" | jq -r '.project_name')
82+
echo "dist=${dist}" >> "${GITHUB_OUTPUT}"
83+
echo "project-name=${project_name}" >> "${GITHUB_OUTPUT}"
84+
85+
# The created artifacts contain both directories that have the binaries
86+
# as well as archives that contain the same content. Remove the duplicate
87+
# directories.
88+
#
89+
# Additionally, the generated config.yaml file may contain substitutions
90+
# which can potentially leak information about the certificates that will
91+
# be used for code-signing in the future.
92+
- name: Clean up Release
93+
run: |
94+
dist="${{steps.metadata.outputs.dist}}"
95+
find "${dist}" -mindepth 1 -maxdepth 1 -type d -exec rm -rf {} \;
96+
rm -f ${dist}/{*.txt,config.yaml,artifacts.json,metadata.json}
97+
98+
- name: Upload Artifacts
99+
uses: actions/upload-artifact@v4
100+
id: release-artifact
101+
with:
102+
name: release-assets
103+
path: ${{steps.metadata.outputs.dist}}/*
104+
retention-days: 1
105+
106+
- name: Create Attestation Jobs
107+
id: create-jobs
108+
run: |
109+
dist="${{steps.metadata.outputs.dist}}"
110+
tar_archives=$(find "${dist}" -type f -name '*.tar.gz' -exec basename {} ".tar.gz" \;)
111+
zip_archives=$(find "${dist}" -type f -name '*.zip' -exec basename {} ".zip" \;)
112+
job_names=$(echo ${tar_archives} ${zip_archives})
113+
job_names=$(echo ${job_names} | sort -u | jq -R -s -c 'split(" ")[:-1]')
114+
echo $job_names
115+
echo "jobs=${job_names}" >> "${GITHUB_OUTPUT}"
116+
117+
release-container:
118+
name: Deploy to Container Registry
119+
runs-on: ubuntu-latest
120+
121+
steps:
122+
- name: Checkout
123+
uses: actions/checkout@v4
124+
125+
- name: Determine latest release
126+
id: latest
127+
env:
128+
GH_TOKEN: ${{ github.token }}
129+
run: |
130+
tag=$(gh release view --json tagName --jq .tagName || true)
131+
echo "tag=${tag}" >> "${GITHUB_OUTPUT}"
132+
133+
- name: Determine Image References
134+
id: image-info
135+
run: |
136+
image_name="ghcr.io/${{ github.repository }}"
137+
138+
image_references=""
139+
# Extract ref prefix for versions and cut the 'v' prefix
140+
if [[ "${{ github.ref }}" == "refs/tags/${{ steps.latest.outputs.tag }}" ]]; then
141+
version=$(echo "${{ steps.latest.outputs.tag }}" | sed -e 's@^v@@')
142+
image_references="${image_name}:${version}"
143+
image_references+=$'\n'
144+
image_references+="${image_name}:latest"
145+
elif [[ "${{ github.ref }}" == "refs/tags/v"* ]]; then
146+
version=$(echo "${{ github.ref }}" | sed -e 's@^refs/tags/v@@')
147+
image_references="${image_name}:${version}"
148+
else
149+
version=$(echo "${{ github.ref }}" | sed -e 's@.*/\(.*\)@\1@')
150+
image_references="${image_name}:${version}"
151+
fi
152+
153+
{
154+
echo "image-name=${image_name}"
155+
echo "image-references<<EOF"
156+
echo "${image_references}"
157+
echo "EOF"
158+
} >> "${GITHUB_OUTPUT}"
159+
160+
- name: Login to Registry
161+
id: login
162+
uses: docker/login-action@v3
163+
with:
164+
registry: ghcr.io
165+
username: ${{ github.actor }}
166+
password: ${{ github.token }}
167+
168+
- name: Collect label information
169+
id: label
170+
run: |
171+
echo "url=${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" >> "${GITHUB_OUTPUT}"
172+
echo "repo=${{ github.event.repository.name }}" >> "${GITHUB_OUTPUT}"
173+
echo "owner=${{ github.repository_owner }}" >> "${GITHUB_OUTPUT}"
174+
echo "timestamp=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> "${GITHUB_OUTPUT}"
175+
176+
- name: Build and push image
177+
id: push
178+
uses: docker/build-push-action@v5.0.0
179+
with:
180+
context: .
181+
push: true
182+
tags: |
183+
${{ steps.image-info.outputs.image-references }}
184+
labels: |
185+
org.opencontainers.image.ref.name=${{ github.ref_name}}
186+
org.opencontainers.image.vendor=Verily Life Sciences
187+
org.opencontainers.image.title=fsh-lint
188+
org.opencontainers.image.licenses=${{ github.event.repository.license }}
189+
org.opencontainers.image.description=${{ github.event.repository.description }}
190+
org.opencontainers.image.documentation=
191+
org.opencontainers.image.url=${{ steps.label.outputs.url }}
192+
org.opencontainers.image.source=${{ steps.label.outputs.url }}
193+
org.opencontainers.image.created=${{ steps.label.outputs.timestamp }}
194+
195+
- name: Attest Build Provenance
196+
uses: actions/attest-build-provenance@v1
197+
id: attest
198+
with:
199+
subject-name: ${{ steps.image-info.outputs.image-name }}
200+
subject-digest: ${{ steps.push.outputs.digest }}
201+
push-to-registry: true
202+
github-token: ${{ github.token }}
203+
204+
# The actions/attest API doesn't make it easy to attest SBOM provenance and
205+
# associate it with a specific build if it's being globbed. An unfortunate
206+
# consequence of that is that the only way to do this is to unroll the
207+
# attestation so that it's done individually per step. This either means
208+
# itemizing it N times, which is ugly -- or to use a matrix strategy to
209+
# attest them all; which is easier to maintain, but requires downloading the
210+
# created artifact. It's not ideal, but it's better than nothing.
211+
attest-release-binaries:
212+
name: Attest Provenance
213+
if: ${{ needs.release-binaries.outputs.jobs != '[]' }}
214+
runs-on: ubuntu-latest
215+
needs: [release-binaries]
216+
strategy:
217+
matrix:
218+
job: ${{ fromJson(needs.release-binaries.outputs.jobs) }}
219+
permissions:
220+
attestations: write
221+
id-token: write
222+
223+
steps:
224+
- name: Download Release Assets
225+
uses: actions/download-artifact@v4
226+
with:
227+
name: ${{ needs.release-binaries.outputs.artifact-name }}
228+
229+
- name: Print Asset Contents
230+
run: ls -l
231+
232+
- name: Unarchive Assets
233+
id: unarchive
234+
run: |
235+
if [[ -f "${{ matrix.job }}.zip" ]]; then
236+
unzip -q "${{ matrix.job }}.zip"
237+
if [[ -d "${{ matrix.job }}" ]]; then
238+
echo "subject-path=${{ matrix.job }}/${{ needs.release-binaries.outputs.project-name }}.exe" >> "${GITHUB_OUTPUT}"
239+
else
240+
echo "subject-path=${{ needs.release-binaries.outputs.project-name }}.exe" >> "${GITHUB_OUTPUT}"
241+
fi
242+
elif [[ -f "${{ matrix.job }}.tar.gz" ]]; then
243+
tar -xzf "${{ matrix.job }}.tar.gz"
244+
if [[ -d "${{ matrix.job }}" ]]; then
245+
echo "subject-path=${{ matrix.job }}/${{ needs.release-binaries.outputs.project-name }}" >> "${GITHUB_OUTPUT}"
246+
else
247+
echo "subject-path=${{ needs.release-binaries.outputs.project-name }}" >> "${GITHUB_OUTPUT}"
248+
fi
249+
else
250+
echo "::error::Failed to find artifact for ${{ matrix.job }}"
251+
exit 1
252+
fi
253+
254+
# Conditionally set the SBOM path if the JSON file exists.
255+
if [[ -f "${{ matrix.job }}.bom.json" ]]; then
256+
echo "sbom-path=${{ matrix.job }}.bom.json" >> "${GITHUB_OUTPUT}"
257+
fi
258+
259+
# Massage the name into something a bit easier to read
260+
name=$(echo "${{ matrix.job }}" | sed "s@_@-@g" | sed "s@x86-64@x86_64@g")
261+
name=$(echo "${name}" | sed "s@-SNAPSHOT@@g")
262+
echo "subject-name=${name}" >> "${GITHUB_OUTPUT}"
263+
264+
- name: Attest SBOM provenance
265+
if: steps.unarchive.outputs.sbom-path != ''
266+
id: sbom
267+
uses: actions/attest-sbom/predicate@v1
268+
with:
269+
sbom-path: ${{ steps.unarchive.outputs.sbom-path}}
270+
271+
- name: Attest build provenance
272+
if: steps.unarchive.outputs.subject-path != ''
273+
uses: actions/attest@v1
274+
with:
275+
subject-path: "${{ steps.unarchive.outputs.subject-path }}"
276+
subject-name: "${{ steps.unarchive.outputs.subject-name }}"
277+
predicate-type: ${{ steps.sbom.outputs.predicate-type }}
278+
predicate-path: ${{ steps.sbom.outputs.predicate-path }}

0 commit comments

Comments
 (0)