This repository has been archived by the owner on Apr 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.gitlab-ci.yml
121 lines (109 loc) · 3.41 KB
/
.gitlab-ci.yml
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
stages:
- lint
- build
- publish
.base_cpp:
image: cogment/orchestrator-build-env:v2.0.0
before_script:
- mkdir build
- cd build
- cmake ..
.base_gh_ssh_agent:
before_script:
## _Inspired by https://docs.gitlab.com/ee/ci/ssh_keys/_
##
## Install ssh-agent if not already installed.
- "command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y )"
## Run ssh-agent
- eval $(ssh-agent -s)
## Add the private key file to ssh-agent
- echo "$GH_REPO_SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
## Create the SSH directory and give it the right permissions
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
## Using the set $SSH_KNOWN_HOSTS to be able to verify remote servers public keys
- echo "$SSH_KNOWN_HOSTS" >> ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
cpp_lint:
extends: .base_cpp
stage: lint
script:
- make format
- git diff --exit-code
apache_licenses_check:
stage: lint
image: registry.gitlab.com/ai-r/apache-license-checker:latest
script:
- apache-license-checker
shellcheck:
image: koalaman/shellcheck-alpine:stable
stage: lint
before_script:
- shellcheck --version
script:
- shellcheck ./scripts/*.sh
shfmt:
image: mvdan/shfmt:v3.1.0-alpine
stage: lint
before_script:
- shfmt -version
script:
- shfmt -i 2 -ci -d ./scripts
build:
extends: .base_cpp
stage: build
script:
- make
.base_docker:
image: docker:19.03.1
services:
- docker:19.03.1-dind
variables:
# Use TLS https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#tls-enabled
DOCKER_HOST: tcp://docker:2376
DOCKER_TLS_CERTDIR: "/certs"
before_script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- docker login -u $DOCKER_HUB_USERNAME -p $DOCKER_HUB_TOKEN
build_docker:
extends: .base_docker
stage: build
script:
- docker pull $CI_REGISTRY_IMAGE:latest || true
- docker build --cache-from $CI_REGISTRY_IMAGE:latest .
except:
# This job is not run on `develop` because `publish_latest` run there and "includes" the build
- develop
publish_latest_to_gitlab_docker_registry:
extends: .base_docker
stage: publish
script:
- docker pull $CI_REGISTRY_IMAGE:latest || true
- docker build --cache-from $CI_REGISTRY_IMAGE:latest --tag $CI_REGISTRY_IMAGE:latest .
- docker push $CI_REGISTRY_IMAGE:latest
only:
- develop
publish_tag_to_dockerhub:
extends: .base_docker
stage: publish
variables:
DOCKER_HUB_IMAGE: "cogment/orchestrator"
script:
- docker pull $CI_REGISTRY_IMAGE:latest || true
- docker build --cache-from $CI_REGISTRY_IMAGE:latest --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG --tag $DOCKER_HUB_IMAGE:$CI_COMMIT_TAG --tag $CI_REGISTRY_IMAGE:latest --tag $DOCKER_HUB_IMAGE:latest .
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
- docker push $CI_REGISTRY_IMAGE:latest
- docker push $DOCKER_HUB_IMAGE:$CI_COMMIT_TAG
- docker push $DOCKER_HUB_IMAGE:latest
only:
- /^v[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+(?:-[[:alnum:]]+)?$/
publish_branch_to_github:
extends: .base_gh_ssh_agent
stage: publish
script:
- git checkout ${CI_COMMIT_BRANCH} # Checkout the branch not the sha1
- git remote add downstream [email protected]:cogment/cogment-orchestrator.git
- git fetch downstream ${CI_COMMIT_BRANCH}
- git push --tags downstream ${CI_COMMIT_BRANCH}:${CI_COMMIT_BRANCH}
only:
- main