-
Notifications
You must be signed in to change notification settings - Fork 1
feat: add ci.yml workflow #75
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,126 @@ | ||
| # CI — lint, test, build for Go backend and React Native/Expo frontend. | ||
| # | ||
| # Gates per coding-standards.md §7: | ||
| # Backend: golangci-lint, go test (short + integration), coverage ≥80% line, | ||
| # go build ./cmd/api/, gqlgen validate | ||
| # Frontend: tsc --noEmit, eslint, prettier --check, jest --ci --coverage ≥80%, | ||
| # graphql-codegen --check | ||
| # | ||
| # Ecosystem detection mirrors dependency-audit.yml so jobs are skipped when | ||
| # the corresponding source tree does not yet exist. | ||
| name: CI | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
| branches: [main] | ||
|
|
||
| permissions: {} | ||
|
|
||
| jobs: | ||
| # ── Detect which source trees are present ────────────────────────────────── | ||
| detect: | ||
| name: Detect ecosystems | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| outputs: | ||
| go: ${{ steps.check.outputs.go }} | ||
| node: ${{ steps.check.outputs.node }} | ||
| steps: | ||
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | ||
|
|
||
| - name: Detect ecosystems | ||
| id: check | ||
| run: | | ||
| if find . -name 'go.mod' -not -path '*/vendor/*' | grep -q .; then | ||
| echo "go=true" >> "$GITHUB_OUTPUT" | ||
| else | ||
| echo "go=false" >> "$GITHUB_OUTPUT" | ||
| fi | ||
|
|
||
| if find . -name 'package.json' -not -path '*/node_modules/*' | grep -q .; then | ||
| echo "node=true" >> "$GITHUB_OUTPUT" | ||
| else | ||
| echo "node=false" >> "$GITHUB_OUTPUT" | ||
| fi | ||
|
Comment on lines
+43
to
+47
|
||
|
|
||
| # ── Go backend ───────────────────────────────────────────────────────────── | ||
| backend: | ||
| name: Backend CI | ||
| needs: detect | ||
| if: needs.detect.outputs.go == 'true' | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | ||
|
|
||
| - uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5 | ||
| with: | ||
| go-version-file: go.mod | ||
| cache: true | ||
|
|
||
| - name: Lint | ||
| uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8 | ||
| with: | ||
| version: v2.1.6 | ||
|
|
||
| - name: Build | ||
| run: go build ./cmd/api/ | ||
|
|
||
| - name: Validate GraphQL schema | ||
| run: go run github.com/99designs/gqlgen validate | ||
|
|
||
| - name: Unit tests | ||
| run: go test ./... -short -count=1 | ||
|
|
||
| - name: Integration tests | ||
| run: go test -tags=integration ./... -count=1 | ||
|
|
||
| - name: Coverage check (≥80% line) | ||
| run: | | ||
| go test ./... -short -count=1 -coverprofile=coverage.out | ||
| pct=$(go tool cover -func=coverage.out \ | ||
| | awk '/^total:/ { gsub(/%/, "", $NF); print $NF }') | ||
| echo "Coverage: ${pct}%" | ||
| awk -v p="$pct" 'BEGIN { | ||
| if (p+0 < 80) { print "Coverage " p "% is below required 80%"; exit 1 } | ||
| }' | ||
|
Comment on lines
+83
to
+91
|
||
|
|
||
| # ── React Native / Expo frontend ─────────────────────────────────────────── | ||
| frontend: | ||
| name: Frontend CI | ||
| needs: detect | ||
| if: needs.detect.outputs.node == 'true' | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | ||
|
|
||
| - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 | ||
| with: | ||
| node-version: lts/* | ||
| cache: npm | ||
|
|
||
| - name: Install dependencies | ||
| run: npm ci | ||
|
|
||
| - name: Type check | ||
| run: npx tsc --noEmit | ||
|
|
||
| - name: Lint | ||
| run: npx eslint . --max-warnings 0 | ||
|
|
||
| - name: Format check | ||
| run: npx prettier --check . | ||
|
Comment on lines
+110
to
+120
|
||
|
|
||
| - name: GraphQL codegen check | ||
| run: npx graphql-codegen --check | ||
|
|
||
| - name: Test + coverage (≥80% branch and line) | ||
| run: npx jest --ci --coverage --coverageThreshold='{"global":{"lines":80,"branches":80}}' | ||
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.
detectsetsgo=trueif anygo.modexists anywhere in the repo, but the backend job assumes a root-module layout (go-version-file: go.modandgo build ./cmd/api/). In a monorepo (or if the Go module lives in a subdir), this will run and then fail becausego.mod/cmd/apiaren’t at repo root. Either restrict detection to the expected module path, or iterate over eachgo.moddirectory and run setup/build/tests within that working directory (similar to howdependency-audit.ymlloops projects).