diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..454d580 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,143 @@ +# build: modemmenu with PAM and the pppd plugin (libpam's and pppd's +# headers, so the AutoPPP test loads the plugin into pppd/test/host.c), on +# the Go of go.mod's toolchain line; gofmt, go.mod and go.sum tidy, go vet +# and the tests with the race detector. +# +# oldest: the same without PAM or pppd's headers (PAM=0 PPPD=0), on +# go.mod's go line (Go 1.22, the oldest it promises; GOTOOLCHAIN=local so +# go.mod's toolchain line doesn't switch it to a newer one). +# +# bbs: bbs's main built, vetted and tested against this checkout of menu +# (go mod edit -replace): bbs logs in with menu's authd client, so a +# change here that breaks bbs fails here, not after bbs next updates. +# +# A change to docs alone runs nothing: the Markdown, docs/, the site's +# files (pages.yml builds them). (paths, not paths-ignore, so that a +# later one can take a file back.) A push runs it on main alone (a +# branch's commits run it as its pull request, not twice), or by hand +# (workflow_dispatch); a newer push to a pull request cancels its older run. +name: CI + +on: + push: + branches: [main] + paths: + - '**' + - '!docs/**' + - '!**.md' + - '!COPYING' + - '!LICENSE' + - '!mkdocs.yml' + - '!.github/workflows/pages.yml' + pull_request: + paths: + - '**' + - '!docs/**' + - '!**.md' + - '!COPYING' + - '!LICENSE' + - '!mkdocs.yml' + - '!.github/workflows/pages.yml' + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: ci-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +jobs: + build: + runs-on: ubuntu-24.04 + # (a hung test ends here, not at GitHub's 6 hours) + timeout-minutes: 15 + steps: + - uses: actions/checkout@v6 + + - uses: actions/setup-go@v7 + with: + go-version-file: go.mod + + - name: libpam's and pppd's headers + run: | + sudo apt-get update -q + sudo apt-get install -y -q --no-install-recommends libpam0g-dev ppp-dev + + - name: gofmt + run: | + out=$(gofmt -l .) + [ -z "$out" ] || { echo "::error::not gofmt'd (gofmt -w .):"; echo "$out"; exit 1; } + + - name: go.mod and go.sum tidy + run: go mod tidy -diff + + - name: Build (PAM, the pppd plugin) + run: make PAM=1 PPPD=1 + + - name: go vet + run: go vet -tags pam ./... + + - name: Tests (race detector) + run: go test -race -tags pam ./... + + oldest: + runs-on: ubuntu-24.04 + timeout-minutes: 15 + env: + GOTOOLCHAIN: local + steps: + - uses: actions/checkout@v6 + + - uses: actions/setup-go@v7 + with: + go-version: "1.22" + + - name: Build (no PAM, no pppd plugin) + run: make PAM=0 PPPD=0 + + - name: go vet + run: go vet ./... + + - name: Tests + run: go test ./... + + bbs: + runs-on: ubuntu-24.04 + timeout-minutes: 20 + env: + GOPRIVATE: github.com/D-Modem/* + steps: + - uses: actions/checkout@v6 + with: + path: menu + + - uses: actions/checkout@v6 + with: + repository: D-Modem/bbs + path: bbs + + - uses: actions/setup-go@v7 + with: + go-version-file: bbs/go.mod + cache-dependency-path: | + bbs/go.sum + menu/go.sum + + - name: bbs against this menu + working-directory: bbs + run: | + go mod edit -replace github.com/D-Modem/menu=../menu + go mod tidy + + - name: Build + working-directory: bbs + run: go build ./... + + - name: go vet + working-directory: bbs + run: go vet ./... + + - name: Tests + working-directory: bbs + run: go test ./...