Skip to content

build(devenv)+ci: devenv.sh dev shell + self-hosted CI (CLI-129)#470

Merged
fhacloid merged 5 commits into
developfrom
fhacloid-cli-129-cycloid-cli-devenvsh-dev-shell-self-hosted-ci
Jul 1, 2026
Merged

build(devenv)+ci: devenv.sh dev shell + self-hosted CI (CLI-129)#470
fhacloid merged 5 commits into
developfrom
fhacloid-cli-129-cycloid-cli-devenvsh-dev-shell-self-hosted-ci

Conversation

@fhacloid

Copy link
Copy Markdown
Contributor

Closes CLI-129.

Brings cycloid-cli onto the same reproducible-toolchain + self-hosted CI pattern as terraform-provider-cycloid and reborn.

Why

The old flake.nix mkShell declared golangci-lint/gci commented out and omitted goimports/shfmt/shellcheck — so make format lint (the pre-commit hook target, Hard Rule 8) couldn't actually run from the declared shell. And there was no GitHub Actions CI at all.

What

build(devenv) — replace flake.nix+flake.lock with devenv.nix/devenv.yaml/devenv.lock:

  • go_1_25 (matches go.mod) + the full Makefile toolchain: go-swagger, golangci-lint, gci, goimports, shfmt, shellcheck, pre-commit, awscli, docker client.
  • Plain go package, not the languages.go module (it injects gopls, which now needs go ≥1.26 on unstable — ahead of go.mod).
  • .envrc: use flakeuse devenv; gitignore .devenv/.

ci.github/workflows/ci.yml on [self-hosted, cycloid], every step inside the devenv shell:

  • authorize (ubuntu): fork-gate by head-repo, not author_association.
  • preflight (ubuntu): skips the backend job cleanly when CY_API_KEY is unset (no red).
  • lint-build: make lint + go vet + go build.
  • test: cy uri interpolate → Scaleway docker login → compose pull → make be-start → wait youdeploy-api healthy (:3001) → go test ./... -p 1 -failfast → teardown.

style — cleared the only pre-existing make lint failures on develop (goimports drift on 4 files + one ST1005 in environments/delete.go) so lint-build is green.

⚠️ Dependency for e2e

The test job needs a CY_API_KEY repo secret (cycloid SaaS key) to resolve the licence + Scaleway registry creds and pull the backend image — same secret tfpro uses. Until it's set, test skips and only lint-build runs.

🤖 Generated with Claude Code

@fhacloid fhacloid force-pushed the fhacloid-cli-129-cycloid-cli-devenvsh-dev-shell-self-hosted-ci branch from c733df6 to ee4744f Compare July 1, 2026 09:53
Comment thread .github/workflows/ci.yml Outdated
# ---------------------------------------------------------------------------
preflight:
name: Preflight (secrets)
runs-on: ubuntu-latest

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[NOTE] use our selfhosted runner for ALL workflow, no more github on deman usage

Comment thread devenv.nix Outdated
shfmt # format-sh

# Dev tooling.
pre-commit # `make install` wires .git/hooks/pre-commit

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[NOTE] We should port it to the devenv integration of pre-commit hooks

Comment thread pkg/testcfg/config.go Outdated
Comment on lines +183 to +191
// On a freshly created catalog the version-presence rows are filled by a
// background cron (~10 min); the plain catalog scan (RefreshCatalogRepository)
// does NOT populate them, so ListStackVersions finds the stack but no branch
// version and we fail with "failed to find latest catalog repo version"
// (BE-1344 / CLI-127). This bites on a cold backend (e.g. CI bringing up the
// compose stack). RefreshCatalogRepositoryVersions hits versions/refresh with
// sync_presence=true, which re-indexes branches+tags synchronously — the same
// call `cy catalog-repository create/update` makes for this exact race, which
// testcfg bypasses by talking to the middleware directly.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[NOTE] shorten comment

@fhacloid fhacloid force-pushed the fhacloid-cli-129-cycloid-cli-devenvsh-dev-shell-self-hosted-ci branch from ee4744f to 50174f6 Compare July 1, 2026 10:00
fhacloid and others added 5 commits July 1, 2026 12:38
The old flake.nix mkShell declared golangci-lint/gci commented out and
omitted goimports/shfmt/shellcheck entirely, so `make format lint` (the
pre-commit hook target) could not run from inside the declared shell.

Add devenv.nix/devenv.yaml/devenv.lock pinning go_1_25 (matches go.mod)
plus the full Makefile toolchain (go-swagger, golangci-lint, gci,
goimports, shfmt, shellcheck, awscli, docker client). Use a plain go
package rather than the languages.go module, which injects gopls (now
requiring go >= 1.26 on unstable, ahead of go.mod). Switch .envrc to
`use devenv`, gitignore .devenv/, and remove flake.nix + flake.lock so the
toolchain has a single source of truth.

Pre-commit hooks move to devenv's git-hooks integration (CLI-130): declared
in devenv.nix and auto-installed on shell entry, replacing the hand-written
.pre-commit-config.yaml and `make install`'s hook wiring. Hooks:
format-and-lint (`make format lint`, the repo's canonical gate) and
no-commit-to-branch (develop/master). No secret-scanner: the old
detect-private-key hook was never enforced (the repo commits many
intentional test/example keys) and it flags all of them for no benefit.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019XPwTdhsXxERJUxG2tZpP2
Clears the only `make lint` failures on develop so the new CI lint-build
job is green: gci/goimports formatting drift, and an ST1005 (error string
ends with punctuation) on the multi-line guidance message in
environments/delete.go — drop the trailing period, message otherwise intact.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019XPwTdhsXxERJUxG2tZpP2
Adapted from terraform-provider-cycloid's workflow. ALL jobs run on the
dedicated [self-hosted, cycloid] runner (no GitHub-hosted usage); every
step executes inside the devenv shell via defaults.run.shell.

- authorize: fork-gate by head-repo == base-repo, not author_association
  (which mislabels private-org members as CONTRIBUTOR). No checkout, so
  safe on the self-hosted runner.
- preflight: skips the backend job cleanly when CY_API_KEY is unset.
- lint-build: make lint (golangci-lint + shellcheck) + go vet + go build.
- test: cy uri interpolate -> Scaleway docker login -> compose pull ->
  make be-start -> wait youdeploy-api healthy (:3001) ->
  go test ./... -p 1 -failfast -> teardown; egress/catalog diagnostic on
  failure. Needs CY_API_KEY. push CI limited to develop/master so a branch
  push + its PR don't run the heavy e2e twice on one runner.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019XPwTdhsXxERJUxG2tZpP2
On a freshly created catalog the version-presence rows are filled by a
background cron (~10 min); RefreshCatalogRepository (the catalog scan) does
NOT fill them, so on a cold backend (CI bringing up the compose stack)
ListStackVersions found stack-e2e-stackforms but no "stacks" branch version
and testcfg failed with "failed to find latest catalog repo version".

`cy catalog-repository create/update` already calls
RefreshCatalogRepositoryVersions (versions/refresh?sync_presence=true) for
exactly this race (CLI-127, 6607bd58), but testcfg created the catalog
through the middleware directly and bypassed it. Call it before listing.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019XPwTdhsXxERJUxG2tZpP2
TestOIDC ran a bare `oidc settings get` before any `set`. Settings are
created on first set, so on a freshly provisioned org (CI cold backend)
the get 404s. Reorder so `set` establishes the settings first, then `get`
reads them back — no assertion change.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019XPwTdhsXxERJUxG2tZpP2
@fhacloid fhacloid force-pushed the fhacloid-cli-129-cycloid-cli-devenvsh-dev-shell-self-hosted-ci branch from 50174f6 to 48da1ca Compare July 1, 2026 10:38
@fhacloid fhacloid merged commit 52092c8 into develop Jul 1, 2026
4 checks passed
@fhacloid fhacloid deleted the fhacloid-cli-129-cycloid-cli-devenvsh-dev-shell-self-hosted-ci branch July 1, 2026 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant