forked from kubernetes/autoscaler
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
100 lines (85 loc) · 3.03 KB
/
.gitlab-ci.yml
File metadata and controls
100 lines (85 loc) · 3.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
include:
- project: 'crusoeenergy/tools'
file: '/templates/go.gitlab-ci.yml'
variables:
CI_IMAGE: "registry.gitlab.com/crusoeenergy/tools/go-ci-1.22"
SUBPROJECT: "cluster-autoscaler"
SUBPROJECT_PATH: "cluster-autoscaler/"
SUBPROJECT_REL_PATH: "./cluster-autoscaler"
REGISTRY: "registry.gitlab.com/crusoeenergy/island/external/k8s-autoscaler"
# we only need amd64 to run autoscaler on C1A VMs
ALL_ARCH: "amd64"
# Docker config
DOCKER_VERSION: "20.10.24-dind"
DOCKER_CLI_PACKAGE: "docker-ce-cli"
DOCKER_REPO_URL: "https://download.docker.com/linux/debian"
DOCKER_GPG_KEY: "/usr/share/keyrings/docker-archive-keyring.gpg"
DOCKER_APT_SOURCE: "/etc/apt/sources.list.d/docker.list"
default:
# Use GCP runner to unblock builds if Crusoe’s runner is unavailable.
tags:
- gitlab-runner-gcp
stages:
- test
- build
test_and_lint:
rules:
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH !~ /^crusoe-cluster-autoscaler-/'
changes: !reference [.code-changes, changes]
- if: '$CI_MERGE_REQUEST_ID'
changes: !reference [.code-changes, changes]
- if: '$CI_COMMIT_TAG && $CI_COMMIT_TAG !~ /^crusoe-cluster-autoscaler-release-[0-9]+\.[0-9]+\.[0-9]+.+/'
script:
- set -euo pipefail
- cd "$SUBPROJECT"
- go test ./cloudprovider/crusoecloud/...
# Remove the tag_semver and pages jobs from merges into main.
# The tag_semver job will be run using a GitHub action instead
# and new versions will be pushed then.
tag_semver:
rules:
- when: never
code_intelligence:
rules:
- when: never
pages:
rules:
- when: never
# Build and push Docker images to the Gitlab registry for internal testing.
build_and_push_image:
stage: build
services:
# Docker-in-Docker to support building images in CI.
- "docker:${DOCKER_VERSION}"
variables:
DOCKER_TLS_CERTDIR: ""
before_script:
- |
set -eux
chmod +x "$SUBPROJECT_PATH/push_image.sh"
# Install Docker CLI for building/pushing images
apt-get update && apt-get install -y apt-transport-https ca-certificates curl gnupg
curl -fsSL "$DOCKER_REPO_URL/gpg" | gpg --dearmor -o "$DOCKER_GPG_KEY"
echo "deb [arch=amd64 signed-by=${DOCKER_GPG_KEY}] ${DOCKER_REPO_URL} bullseye stable" > "$DOCKER_APT_SOURCE"
apt-get update && apt-get install -y "$DOCKER_CLI_PACKAGE"
# Authenticate to the GitLab container registry
docker login -u gitlab-ci-token -p "$CI_JOB_TOKEN" registry.gitlab.com
script:
- |
set -eux
cd "$SUBPROJECT_PATH"
# Build for amd64 architecture
make build-arch-amd64
# Set registry info and target tag
export REGISTRY="$REGISTRY"
export TAG="$CI_COMMIT_REF_NAME"
export ALL_ARCH="$ALL_ARCH"
# Build, then push manifest
make make-image-arch-amd64
docker push "$REGISTRY/cluster-autoscaler-amd64:$TAG"
rules:
# Always run this job if on default branch or in a merge request.
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
when: always
- if: '$CI_MERGE_REQUEST_ID'
when: always