-
Notifications
You must be signed in to change notification settings - Fork 3
ci: improve PR and release automation #155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
521e77c
ci: label pull requests and validate changesets
mynameistito 1668ade
test: validate npm package contents
mynameistito 0fd4783
ci: add workflow and documentation checks
mynameistito 29ae796
docs: document repository automation
mynameistito ce6d23c
fix(ci): make workflow security checks portable
mynameistito aa9097b
fix(ci): correct workflow security reporters
mynameistito 125d749
chore(deps): set update cooldowns
mynameistito b541d1f
fix(ci): address review findings
mynameistito 803652f
fix(package): reject root test and script files
mynameistito 2264687
fix(ci): harden fork checks and release exemptions
mynameistito 326c2a9
fix(package): reject test and build directories
mynameistito 2b043f3
fix(ci): enable shellcheck for workflows
mynameistito File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| name: Documentation links | ||
|
|
||
| on: | ||
| pull_request: | ||
| paths: | ||
| - README.md | ||
| - apps/web/** | ||
| - packages/*/README.md | ||
| - .lycheeignore | ||
| schedule: | ||
| - cron: "23 9 * * 1" | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| links: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
| with: | ||
| persist-credentials: false | ||
| - name: Check documentation links | ||
| uses: lycheeverse/lychee-action@e7477775783ea5526144ba13e8db5eec57747ce8 # v2 | ||
| with: | ||
| args: >- | ||
| --verbose --no-progress --max-retries 3 --retry-wait-time 2 --timeout 20 --exclude-mail --exclude '^/' --accept 200,206,301,302,307,308,429 README.md 'apps/web/**/*.md' 'apps/web/**/*.mdx' 'packages/*/README.md' | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| name: PR metadata | ||
|
|
||
| on: | ||
| pull_request_target: | ||
| types: [opened, reopened, synchronize, ready_for_review, labeled, unlabeled] | ||
|
|
||
| concurrency: | ||
| group: pr-metadata-${{ github.event.pull_request.number }}-${{ github.event.action }}-${{ github.event.label.name || 'none' }} | ||
| cancel-in-progress: ${{ github.event.action == 'synchronize' }} | ||
|
|
||
| permissions: | ||
| contents: read | ||
| issues: write | ||
| pull-requests: read | ||
|
|
||
| jobs: | ||
| metadata: | ||
| if: >- | ||
| (github.event.action != 'labeled' && github.event.action != 'unlabeled') || github.event.label.name == 'skip-changeset' | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout trusted default-branch automation | ||
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
| with: | ||
| ref: ${{ github.event.repository.default_branch }} | ||
| persist-credentials: false | ||
| - name: Setup Bun | ||
| uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0 | ||
| with: | ||
| bun-version: 1.4.2 | ||
| - name: Label pull request and validate Changeset coverage | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| GITHUB_REPOSITORY: ${{ github.repository }} | ||
| PR_NUMBER: ${{ github.event.pull_request.number }} | ||
| PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }} | ||
| run: bun scripts/pr-metadata.ts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| name: Workflow security | ||
|
|
||
| on: | ||
| pull_request: | ||
| paths: | ||
| - .github/workflows/** | ||
| - .github/actions/** | ||
| - .github/dependabot.yml | ||
| - .github/zizmor.yml | ||
| push: | ||
| branches: [main] | ||
| paths: | ||
| - .github/workflows/** | ||
| - .github/actions/** | ||
| - .github/dependabot.yml | ||
| - .github/zizmor.yml | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| actionlint: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
| with: | ||
| persist-credentials: false | ||
| - name: actionlint | ||
| uses: raven-actions/actionlint@3d39aea434753780c3b3d4a1a31c854b4dbf49d7 # v2 | ||
| with: | ||
| version: 1.7.11 | ||
| cache: false | ||
| shellcheck: true | ||
| pyflakes: false | ||
|
|
||
| zizmor: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout trusted security configuration | ||
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
| with: | ||
| ref: ${{ github.event.repository.default_branch }} | ||
| path: trusted | ||
| persist-credentials: false | ||
| - name: Checkout workflow changes for analysis | ||
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
| with: | ||
| repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }} | ||
| ref: ${{ github.event.pull_request.head.sha || github.sha }} | ||
| path: source | ||
| persist-credentials: false | ||
| - name: Select trusted zizmor configuration | ||
| id: zizmor-config | ||
| shell: bash | ||
| env: | ||
| IS_FORK_PR: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository }} | ||
| run: | | ||
| if [[ -f trusted/.github/zizmor.yml ]]; then | ||
| echo "path=trusted/.github/zizmor.yml" >> "$GITHUB_OUTPUT" | ||
| elif [[ "$IS_FORK_PR" == "true" ]]; then | ||
| echo "::error::The trusted default branch has no zizmor configuration; refusing to use fork-provided configuration." | ||
| exit 1 | ||
| else | ||
| echo "::warning::The trusted branch has no zizmor configuration yet; using same-repository configuration for this bootstrap run." | ||
| echo "path=source/.github/zizmor.yml" >> "$GITHUB_OUTPUT" | ||
|
mynameistito marked this conversation as resolved.
|
||
| fi | ||
| - name: zizmor | ||
| uses: zizmorcore/zizmor-action@cc914d7f3750a2d13d75c7f184a1060aa0e9d482 # v0.6.4 | ||
| with: | ||
| advanced-security: false | ||
| annotations: true | ||
| config: ${{ steps.zizmor-config.outputs.path }} | ||
| inputs: source/.github | ||
| version: 1.30.1 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| # These findings are limited to existing, intentionally reviewed workflow | ||
| # patterns. Keep the ignores line-specific so new findings remain visible. | ||
| rules: | ||
| dangerous-triggers: | ||
| ignore: | ||
| - deploy-preview.yml:3 | ||
| - deploy.yml:3 | ||
| # Required for fork-safe labeling; this workflow checks out only the trusted default branch. | ||
| - pr-metadata.yml:3 | ||
| excessive-permissions: | ||
| ignore: | ||
| - deploy-preview.yml:20 | ||
| - deploy-preview.yml:21 | ||
| adhoc-packages: | ||
| ignore: | ||
| - release.yml:35 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
packages/opencode-usage-limits/__tests__/package-tarball.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| import { describe, expect, it } from "vitest"; | ||
|
|
||
| import { isUnexpectedPackagePath } from "../../../scripts/package-tarball-helpers.ts"; | ||
|
|
||
| describe("package tarball paths", () => { | ||
| it("rejects package source, test, and script directories", () => { | ||
| expect(isUnexpectedPackagePath("src/index.ts")).toBeTruthy(); | ||
| expect(isUnexpectedPackagePath("__tests__/plugin.test.ts")).toBeTruthy(); | ||
| expect(isUnexpectedPackagePath("scripts/test-package.ts")).toBeTruthy(); | ||
| }); | ||
|
|
||
| it("rejects root-level test and build directories", () => { | ||
| expect(isUnexpectedPackagePath("test/fixtures/sample.ts")).toBeTruthy(); | ||
| expect(isUnexpectedPackagePath("tests/fixtures/sample.ts")).toBeTruthy(); | ||
| expect(isUnexpectedPackagePath("spec/plugin.spec.ts")).toBeTruthy(); | ||
| expect(isUnexpectedPackagePath("build/output.js")).toBeTruthy(); | ||
| }); | ||
|
|
||
| it("rejects root-level test and build scripts", () => { | ||
| expect(isUnexpectedPackagePath("test-package.ts")).toBeTruthy(); | ||
| expect(isUnexpectedPackagePath("build.ts")).toBeTruthy(); | ||
| expect(isUnexpectedPackagePath("plugin.test.ts")).toBeTruthy(); | ||
| }); | ||
|
|
||
| it("allows intended root package files and build output", () => { | ||
| expect(isUnexpectedPackagePath("README.md")).toBeFalsy(); | ||
| expect(isUnexpectedPackagePath("dist/index.mjs")).toBeFalsy(); | ||
| expect(isUnexpectedPackagePath("usage-limits.schema.json")).toBeFalsy(); | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.