mirror of
https://gitlab.com/TECHNOFAB/nix-gitlab-ci.git
synced 2025-12-12 02:00:13 +01:00
feat(v2): initial v2 implementation
add multi-arch (arm & x64) image add multiple pipelines (ci now creates the "default" pipeline as a shorthand) simplify devenv flake input merge all cache options together, now $NIX_CI_CACHE_STRATEGY decides how the cache works setup_nix_ci and finalize_nix_ci are now flake packages and work standalone the specific image is not needed anymore, any image with the right dependencies works runner cache is not the default anymore (because it sucked most of the time) the pipeline is selected by $NIX_CI_PIPELINE_NAME or if empty by $CI_PIPELINE_SOURCE, so for the old behaviour $NIX_CI_PIPELINE_NAME=default is needed, future work will be needed to handle this more nicely
This commit is contained in:
parent
016e6c9dc7
commit
586fb88b9d
6 changed files with 409 additions and 412 deletions
|
|
@ -1,29 +1,37 @@
|
|||
spec:
|
||||
inputs:
|
||||
image_tag:
|
||||
cache_strategy:
|
||||
type: string
|
||||
description: "latest | latest-cachix | latest-attic etc."
|
||||
default: latest
|
||||
description: |
|
||||
(empty for auto) | none | runner | cachix | attic
|
||||
When left empty $NIX_CI_CACHE_STRATEGY will be used, which defaults to none
|
||||
default: ""
|
||||
cache_files:
|
||||
type: array
|
||||
description: |
|
||||
Files to use as the cache key for the generated pipeline yaml.
|
||||
If you use "ci.nix" to define CI, add that here for example
|
||||
default: ["flake.nix", "flake.lock"]
|
||||
disable_cache:
|
||||
type: string
|
||||
description: |
|
||||
Disables any caching provided by this component. Set to any non-empty value to disable caching.
|
||||
default: ""
|
||||
---
|
||||
stages:
|
||||
- build
|
||||
- trigger
|
||||
variables:
|
||||
NIX_CI_DISABLE_CACHE: "$[[ inputs.disable_cache ]]${NIX_CI_DISABLE_CACHE:-}"
|
||||
# which version of the image should be used
|
||||
_NIX_CI_VERSION: ${NIX_CI_VERSION}
|
||||
_NIX_CI_IMAGE: ${NIX_CI_IMAGE:-registry.gitlab.com/technofab/nix-gitlab-ci/nix-ci:${_NIX_CI_VERSION}}
|
||||
# force build the pipeline yaml
|
||||
_NIX_CI_FORCE_BUILD: ${NIX_CI_FORCE_BUILD}
|
||||
# disable caching on the child pipeline jobs
|
||||
_NIX_CI_DISABLE_CACHE: ${NIX_CI_DISABLE_CACHE}
|
||||
# type of cache strategy to use (none, runner, attic, cachix)
|
||||
_CACHE_STRATEGY_TMP: $[[ inputs.cache_strategy ]]
|
||||
_NIX_CI_CACHE_STRATEGY: ${NIX_CI_CACHE_STRATEGY:-${_CACHE_STRATEGY_TMP:-none}}
|
||||
# for multiple pipelines
|
||||
_NIX_CI_PIPELINE_NAME: ${NIX_CI_PIPELINE_NAME:-${CI_PIPELINE_SOURCE:-default}}
|
||||
nix-ci:build:
|
||||
stage: build
|
||||
image: registry.gitlab.com/technofab/nix-gitlab-ci/nix-ci:$[[ inputs.image_tag ]]
|
||||
image: $_NIX_CI_IMAGE
|
||||
cache:
|
||||
- key:
|
||||
files: $[[ inputs.cache_files ]]
|
||||
|
|
@ -36,7 +44,7 @@ nix-ci:build:
|
|||
# generated-gitlab-ci.yml exists in the cache
|
||||
- '[ -f "generated-gitlab-ci.yml" ] && export CACHED=true && echo "A cached pipeline file exists (skip cache with NIX_CI_FORCE_BUILD)" || true'
|
||||
# allow the user to manually skip the cache (when the key files are not correctly configured etc.)
|
||||
- '[ -n "$NIX_CI_FORCE_BUILD" ] && unset CACHED && echo "Caching skipped for this job (through NIX_CI_FORCE_BUILD)" || true'
|
||||
- '[ -n "$_NIX_CI_FORCE_BUILD" ] && unset CACHED && echo "Caching skipped for this job (through NIX_CI_FORCE_BUILD)" || true'
|
||||
# only setup when we need to generate the pipeline yaml
|
||||
- 'if [ -z "$CACHED" ]; then source setup_nix_ci; fi'
|
||||
script:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue