From d8c462e307d1bd898e8667539a2509e4413641a8 Mon Sep 17 00:00:00 2001 From: adelnizamutdinov Date: Sun, 20 Sep 2026 14:50:32 +0000 Subject: [PATCH] Run native Moon CI with reusable project tasks --- .github/workflows/ci.yaml | 47 +++++++++++++++++++-------------------- .moon/tasks/all.yml | 3 +-- README.md | 18 ++++++++------- moon.yml | 17 ++++++++++---- 4 files changed, 47 insertions(+), 38 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 151100e..0d59874 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -16,6 +16,7 @@ jobs: - uses: actions/checkout@v7 with: fetch-depth: 0 + filter: blob:none - uses: actions/setup-go@v7 id: go with: @@ -33,29 +34,27 @@ jobs: restore-keys: | go-v1-${{ runner.os }}-${{ runner.arch }}-${{ steps.go.outputs.go-version }}-${{ hashFiles('go.mod', 'go.sum') }}- go-v1-${{ runner.os }}-${{ runner.arch }}-${{ steps.go.outputs.go-version }}- - - uses: pkgxdev/setup@v5 - - name: Identify the CI toolchain - id: toolchain - run: | - mkdir -p "$HOME/.cache/go-build" - fingerprint="$( - { - go version - pkgx moon --version - } | sha256sum - )" - fingerprint="${fingerprint%% *}" - echo "fingerprint=$fingerprint" >> "$GITHUB_OUTPUT" - echo "CI_TOOLCHAIN=$fingerprint" >> "$GITHUB_ENV" - - name: Restore Moon task results and outputs - id: moon-cache - uses: actions/cache@v6 + - uses: moonrepo/setup-toolchain@v0 + with: + moon-version: "2.5.5" + - run: mkdir -p "$HOME/.cache/go-build" + - name: Check affected tasks + id: ci + run: moon ci + - name: Report Moon CI results + if: "!cancelled() && steps.ci.outcome != 'skipped'" + uses: moonrepo/run-report-action@v1 with: + access-token: ${{ secrets.GITHUB_TOKEN }} + skip-comment: true + - name: Upload Moon reports + if: always() + uses: actions/upload-artifact@v7 + with: + name: moon-reports-${{ github.run_attempt }} path: | - .moon/cache/hashes - .moon/cache/outputs - key: moon-v1-${{ runner.os }}-${{ runner.arch }}-${{ steps.toolchain.outputs.fingerprint }}-${{ github.sha }} - restore-keys: | - moon-v1-${{ runner.os }}-${{ runner.arch }}-${{ steps.toolchain.outputs.fingerprint }}- - - name: Check - run: pkgx moon run check + .moon/cache/ciReport.json + .moon/cache/runReport.json + if-no-files-found: ignore + include-hidden-files: true + retention-days: 14 diff --git a/.moon/tasks/all.yml b/.moon/tasks/all.yml index 3719789..4dc1d06 100644 --- a/.moon/tasks/all.yml +++ b/.moon/tasks/all.yml @@ -6,7 +6,6 @@ taskOptions: unixShell: bash outputStyle: stream implicitInputs: - - $CI - - $CI_TOOLCHAIN - /.moon/**/*.yml - moon.yml + - /.github/workflows/ci.yaml diff --git a/README.md b/README.md index f4d1e40..e3a6ecb 100644 --- a/README.md +++ b/README.md @@ -145,17 +145,19 @@ by the application, commonly `traceparent`, `tracestate`, and `baggage`. [Moon](https://moonrepo.dev) runs the complete project check. ```sh -pkgx moon run check +moon run check ``` -CI runs the same check with formatting verification and Go vet. It restores Go -modules, compiler output, and golangci-lint data, saving an updated cache for each -commit. Moon restores only its portable `hashes` and `outputs` directories, keyed -by runner architecture and the resolved Go and Moon toolchain. +CI follows [Moon's CI guide](https://moonrepo.dev/docs/guides/ci): full Git +history, source-based affected selection, and plain `moon ci`. It runs the same +project tasks used locally; aggregate checks and maintenance commands are excluded +from automatic selection. The same `moon.yml` also works as a Listenbox submodule. -Moon hashes Go sources, module files, embedded templates, fixtures, golden files, -and CI configuration inputs before reusing a result. When Moon selects the test -task, Go executes its tests without reusing its own test-result cache. +Go modules, compiler output, and golangci-lint data are cached. Moon task results +are not restored across CI runs. Sources, module files, fixtures, templates, and +configuration determine affected tasks; `$CI` is not an input. CI verifies +formatting, and selected Go tests bypass Go's test-result cache. Native Moon +reports are attached to the workflow, including on failure. ## License diff --git a/moon.yml b/moon.yml index b9c55e0..ad9eb4d 100644 --- a/moon.yml +++ b/moon.yml @@ -1,5 +1,11 @@ toolchains: default: system +fileGroups: + sources: + - go.mod + - go.sum + - ./**/*.go + - internal/**/*.gotmpl tasks: mod-download: inputs: @@ -12,7 +18,7 @@ tasks: cache: true test: deps: - - oasmith:mod-download + - ~:mod-download inputs: - ./**/*.go - internal/**/*.gotmpl @@ -26,7 +32,7 @@ tasks: cache: true lint: deps: - - oasmith:mod-download + - ~:mod-download inputs: - ./**/*.go - .golangci.yaml @@ -48,5 +54,8 @@ tasks: cache: true check: deps: - - oasmith:lint - - oasmith:test + - ~:lint + - ~:test + inputs: [] + options: + runInCI: false