This repository was archived by the owner on Oct 17, 2026. It is now read-only.
Repository navigation
chore(ci): add required build workflow for branch ruleset #40
Merged
+111
−0
Merged
Changes from all commits
Commits
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| name: build | ||
|
|
||
| on: | ||
| pull_request: | ||
| push: | ||
| branches: | ||
| - main | ||
| - master | ||
|
|
||
| concurrency: | ||
| group: build-${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 30 | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Node | ||
| if: hashFiles('package.json') != '' | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '24' | ||
|
|
||
| - name: Detect toolchain and build | ||
| shell: bash | ||
| run: | | ||
| set -euo pipefail | ||
|
|
||
| has_npm_script() { | ||
| local script="$1" | ||
| node -e "const p=require('./package.json'); process.exit(p.scripts && p.scripts['$script'] ? 0 : 1)" | ||
| } | ||
|
|
||
| if [ -f package.json ]; then | ||
| echo "Detected Node.js $(node -v)" | ||
| if [ -f pnpm-lock.yaml ]; then | ||
| corepack enable | ||
| pnpm install --frozen-lockfile || pnpm install | ||
| RUN="pnpm run" | ||
| elif [ -f yarn.lock ]; then | ||
| corepack enable | ||
| yarn install --frozen-lockfile || yarn install | ||
| RUN="yarn" | ||
| else | ||
| if [ -f package-lock.json ]; then npm ci || npm install; else npm install; fi | ||
| RUN="npm run" | ||
| fi | ||
|
|
||
| if [ -f hardhat.config.js ] || [ -f hardhat.config.ts ] || [ -f hardhat.config.cjs ]; then | ||
| echo "Hardhat project — compile" | ||
| npx hardhat compile | ||
| exit 0 | ||
| fi | ||
| if [ -f foundry.toml ]; then | ||
| curl -L https://foundry.paradigm.xyz | bash | ||
| export PATH="$HOME/.foundry/bin:$PATH" | ||
| foundryup | ||
| forge build | ||
| exit 0 | ||
| fi | ||
| if has_npm_script build; then | ||
| $RUN build | ||
| exit 0 | ||
| fi | ||
| if has_npm_script typecheck; then | ||
| $RUN typecheck | ||
| exit 0 | ||
| fi | ||
| if has_npm_script lint; then | ||
| $RUN lint | ||
| exit 0 | ||
| fi | ||
| echo "No build/typecheck/lint script; install succeeded" | ||
| exit 0 | ||
| fi | ||
|
|
||
| if [ -f pyproject.toml ] || [ -f setup.py ] || [ -f requirements.txt ] || [ -f Pipfile ]; then | ||
| echo "Detected Python" | ||
| python -m pip install --upgrade pip | ||
| if [ -f requirements.txt ]; then pip install -r requirements.txt || true; fi | ||
| if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt || true; fi | ||
| if [ -f pyproject.toml ]; then | ||
| pip install -e ".[dev]" 2>/dev/null || pip install -e . 2>/dev/null || true | ||
| fi | ||
| python -m compileall -q . | ||
| exit 0 | ||
| fi | ||
|
|
||
| if [ -f Cargo.toml ]; then | ||
| cargo check --all-targets | ||
| exit 0 | ||
| fi | ||
|
|
||
| if [ -f go.mod ]; then | ||
| go test ./... | ||
| exit 0 | ||
| fi | ||
|
|
||
| if [ -f Makefile ] && grep -qE '^(build|test|check):' Makefile; then | ||
| if grep -qE '^build:' Makefile; then make build | ||
| elif grep -qE '^check:' Makefile; then make check | ||
| else make test; fi | ||
| exit 0 | ||
| fi | ||
|
|
||
| echo "No standard toolchain detected; verifying repository contents" | ||
| test -n "$(ls -A)" | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a PR changes
package.jsonwithout updatingpackage-lock.json,npm cicorrectly exits with an error, but this fallback immediately runsnpm install, updates the lockfile only inside the runner, and can let the requiredbuildcheck pass with an unreproducible dependency manifest. Thenpm cidocumentation explicitly says it errors rather than updating an inconsistent lockfile, so remove the fallback and allow that failure to surface.Useful? React with 👍 / 👎.