-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
125 lines (113 loc) · 3.83 KB
/
Copy path.gitlab-ci.yml
File metadata and controls
125 lines (113 loc) · 3.83 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
stages:
- build
- test
- publish
# Avoid duplicate pipelines: when a branch has an open MR, only the MR
# pipeline runs; pushes to branches without an MR still get a pipeline.
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
when: never
- if: $CI_COMMIT_BRANCH
- if: $CI_COMMIT_TAG
variables: &base_vars
DEBIAN_COMMON_PACKAGES: git gcc g++ ninja-build
GIT_DEPTH: 0 # avoid shallow clone since version is based on latest tag
GIT_FETCH_EXTRA_FLAGS: --tags
GIT_SUBMODULE_STRATEGY: normal
# Every runner on this instance picks up untagged jobs, and some of them are
# arm64. The test jobs run binaries produced by the build jobs, and docker:push
# publishes the image produced by docker:build, so all jobs in a pipeline have
# to land on the same architecture.
.amd64_runner:
tags:
- amd64
.ubuntu_base:
extends: .amd64_runner
image: "ubuntu:${UBUNTU_TAG}"
variables:
<<: *base_vars
before_script:
- uname -a
- apt-get update
- apt-get install -y -qq $INSTALL_PACKAGES $DEBIAN_COMMON_PACKAGES
.ubuntu_build_template:
extends: .ubuntu_base
stage: build
variables:
INSTALL_PACKAGES: python3 cmake
script:
- printf "Building TMW Athena version %s on ubuntu:%s\n" "$(git describe --tags HEAD)" "${UBUNTU_TAG}"
- cmake -S . -B build/${UBUNTU_TAG} -G Ninja -DCMAKE_INSTALL_PREFIX=$HOME/.local -DTMWA_BUILD_TESTS=ON
# Run after configure so generated headers (e.g. *_conf.hpp) are present.
- python3 tools/check-fwd.py
- cmake --build build/${UBUNTU_TAG}
- cmake --install build/${UBUNTU_TAG}
artifacts:
expire_in: 30 mins
paths:
- build/${UBUNTU_TAG}/
.ubuntu_test_template:
extends: .ubuntu_base
stage: test
variables:
INSTALL_PACKAGES: python3 gdb cmake
script:
- printf "Testing TMW Athena version %s on ubuntu:%s\n" "$(git describe --tags HEAD)" "${UBUNTU_TAG}"
- ctest --test-dir build/${UBUNTU_TAG} --output-on-failure
ubuntu2404:build:
extends: .ubuntu_build_template
variables:
UBUNTU_TAG: "24.04"
ubuntu2404:test:
extends: .ubuntu_test_template
variables:
UBUNTU_TAG: "24.04"
needs:
- job: ubuntu2404:build
artifacts: true
ubuntu2604:build:
extends: .ubuntu_build_template
variables:
UBUNTU_TAG: "26.04"
ubuntu2604:test:
extends: .ubuntu_test_template
variables:
UBUNTU_TAG: "26.04"
needs:
- job: ubuntu2604:build
artifacts: true
# Build Docker image for testing
docker:build:
extends: .amd64_runner
stage: build
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
script:
- /kaniko/executor --no-push --context "$CI_PROJECT_DIR" --dockerfile "$CI_PROJECT_DIR/Dockerfile" --tarPath tmwa-server.tar
artifacts:
name: "tmwa-server-$CI_COMMIT_SHORT_SHA"
expire_in: 1 week
paths:
- tmwa-server.tar
# Push Docker image to registry
docker:push:
extends: .amd64_runner
stage: publish
needs: ["docker:build"]
image:
name: quay.io/skopeo/stable
entrypoint: [""]
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: never
- if: '$DOCKER_HUB_TOKEN && $DOCKER_HUB_USERNAME && $CI_COMMIT_REF_PROTECTED == "true"'
when: on_success
- when: never
script:
- export DOCKER_HUB_IMAGE="${DOCKER_HUB_IMAGE:-docker.io/${DOCKER_HUB_USERNAME}/${CI_PROJECT_NAME}}"
- export IMAGE_TAG="${CI_COMMIT_TAG:-${CI_COMMIT_SHORT_SHA}}"
- skopeo copy --insecure-policy --dest-creds "${DOCKER_HUB_USERNAME}:${DOCKER_HUB_TOKEN}" docker-archive:tmwa-server.tar "docker://${DOCKER_HUB_IMAGE}:${IMAGE_TAG}"
- if [ "$CI_COMMIT_BRANCH" = "$CI_DEFAULT_BRANCH" ] && [ -z "$CI_COMMIT_TAG" ]; then skopeo copy --insecure-policy --dest-creds "${DOCKER_HUB_USERNAME}:${DOCKER_HUB_TOKEN}" docker-archive:tmwa-server.tar "docker://${DOCKER_HUB_IMAGE}:latest"; fi