|
| 1 | +# Contributing |
| 2 | + |
| 3 | +Thanks for your interest in contributing! This document covers the development |
| 4 | +workflow needed to get a change ready to commit and push. |
| 5 | + |
| 6 | +## Prerequisites |
| 7 | + |
| 8 | +- [Docker](https://docs.docker.com/get-docker/) with [Buildx](https://docs.docker.com/buildx/working-with-buildx/) |
| 9 | +- Git |
| 10 | + |
| 11 | +That's it. Everything else (Node, npm, linters, the test environment) runs |
| 12 | +inside containers driven by `docker buildx bake`. |
| 13 | + |
| 14 | +## Pre-commit checklist |
| 15 | + |
| 16 | +Run these commands, in order, before committing any change to `src/`, |
| 17 | +`__tests__/`, `package.json`, `package-lock.json`, or `action.yml`: |
| 18 | + |
| 19 | +```sh |
| 20 | +# 1. Format source, refresh node_modules, regenerate dist/index.js |
| 21 | +docker buildx bake pre-checkin |
| 22 | + |
| 23 | +# 2. Run the test suite (unit + integration; needs network for release downloads) |
| 24 | +docker buildx bake test |
| 25 | + |
| 26 | +# 3. Validate that everything is committed and reproducible |
| 27 | +docker buildx bake validate |
| 28 | +``` |
| 29 | + |
| 30 | +`validate` is what CI runs. If it passes locally, your PR will pass the |
| 31 | +`validate` job too. |
| 32 | + |
| 33 | +### Why `pre-checkin` matters |
| 34 | + |
| 35 | +The repository ships the compiled action as `dist/index.js`. CI's |
| 36 | +`build-validate` target rebuilds it inside an Alpine container and fails if the |
| 37 | +checked-in bytes don't match. **You must commit the `dist/` output produced by |
| 38 | +`docker buildx bake pre-checkin`** — running `npm run build` on macOS or a |
| 39 | +non-Alpine host produces slightly different bytes and `validate` will reject |
| 40 | +the PR. |
| 41 | + |
| 42 | +If you forget and CI complains about a `dist/` diff, just run: |
| 43 | + |
| 44 | +```sh |
| 45 | +docker buildx bake build |
| 46 | +git add dist/ |
| 47 | +git commit --amend --no-edit |
| 48 | +git push --force-with-lease |
| 49 | +``` |
| 50 | + |
| 51 | +## Available bake targets |
| 52 | + |
| 53 | +| Target | Purpose | |
| 54 | +| --------------- | --------------------------------------------------- | |
| 55 | +| `build` | Regenerate `dist/index.js` only | |
| 56 | +| `format` | Run Prettier on `src/` and `__tests__/` | |
| 57 | +| `vendor` | Refresh `node_modules` / `package-lock.json` | |
| 58 | +| `pre-checkin` | `vendor` + `format` + `build` (run before commits) | |
| 59 | +| `lint` | Prettier check + ESLint | |
| 60 | +| `build-validate`| Verify `dist/index.js` matches a fresh build | |
| 61 | +| `vendor-validate`| Verify `package-lock.json` is in sync | |
| 62 | +| `validate` | `lint` + `build-validate` + `vendor-validate` | |
| 63 | +| `test` | Run Jest with coverage in an Alpine container | |
| 64 | + |
| 65 | +## Tests |
| 66 | + |
| 67 | +`docker buildx bake test` runs the full Jest suite, including integration |
| 68 | +tests that: |
| 69 | + |
| 70 | +- Download real GoReleaser releases from GitHub |
| 71 | +- Verify `checksums.txt` against the downloaded archive |
| 72 | +- Verify the cosign sigstore bundle (`cosign` is installed in the test image) |
| 73 | + |
| 74 | +These need outbound network access. If you're behind a restrictive proxy or |
| 75 | +offline, those tests will fail — that's expected. |
| 76 | + |
| 77 | +## Commit messages |
| 78 | + |
| 79 | +Use [Conventional Commits](https://www.conventionalcommits.org/) (`feat:`, |
| 80 | +`fix:`, `test:`, `docs:`, `chore:`, `ci:`, …). Keep the subject ≤72 chars. |
| 81 | + |
| 82 | +## Pull requests |
| 83 | + |
| 84 | +- Target `master`. |
| 85 | +- Make sure `docker buildx bake validate` and `docker buildx bake test` pass. |
| 86 | +- One logical change per PR is easier to review. |
| 87 | +- The `signing` CI job and `goreleaser-pro` matrix entries are skipped on PRs |
| 88 | + from forks because they need repository secrets — that's expected and not |
| 89 | + something you need to fix. |
0 commit comments