forked from jasmin-lang/jasmin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
156 lines (145 loc) · 4.22 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
stages:
- prepare
- prove
- build
- test
- deploy
image: nixos/nix:2.3.12
variables:
NIX_PATH: nixpkgs=channel:nixpkgs-unstable
EXTRA_SUBSTITUTERS: https://jasmin.cachix.org
EXTRA_PUBLIC_KEYS: jasmin.cachix.org-1:aA5r1ovq4HYKUa+8QHVvIP7K6Fi9L75b0SaN/sooWSY=
NIXOS_PUBLIC_KEY: cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
.common:
before_script:
- nix-shell -p nix-info --run 'nix-info -m'
- >-
nix-shell
--extra-substituters "$EXTRA_SUBSTITUTERS"
--trusted-public-keys "$NIXOS_PUBLIC_KEY $EXTRA_PUBLIC_KEYS"
--arg inCI true
$EXTRA_NIX_ARGUMENTS
--run 'echo done'
cache dependencies:
stage: prepare
extends: .common
variables:
EXTRA_NIX_ARGUMENTS: --arg coqDeps true --arg ocamlDeps true --arg testDeps true
environment: cachix
only:
variables:
- $CACHIX_SIGNING_KEY
script:
- >-
nix-shell -p cachix --run
'nix-store --query --references $(nix-instantiate --arg devTools false default.nix)
| xargs nix-store --realise
| xargs nix-store --query --requisites
| cachix push jasmin'
coq:
stage: prove
variables:
EXTRA_NIX_ARGUMENTS: --arg coqDeps true
extends: .common
script:
- nix-shell --arg inCI true $EXTRA_NIX_ARGUMENTS --run 'make -j$NIX_BUILD_CORES -C proofs'
- nix-shell --arg inCI true $EXTRA_NIX_ARGUMENTS --run 'make -j$NIX_BUILD_CORES -C compiler CIL'
artifacts:
paths:
- compiler/CIL/
ocaml:
stage: build
variables:
EXTRA_NIX_ARGUMENTS: --arg ocamlDeps true
extends: .common
needs:
- coq
dependencies:
- coq
script:
- nix-shell --arg inCI true $EXTRA_NIX_ARGUMENTS --run 'make -j$NIX_BUILD_CORES -C compiler'
artifacts:
paths:
- compiler/_build/
- compiler/jasminc.native
opam:
stage: prove
variables:
OPAMROOTISOK: 'true'
OPAMROOT: mapo
PREFIX: jasmin-$CI_COMMIT_REF_NAME-$CI_COMMIT_SHORT_SHA
cache:
paths:
- $OPAMROOT
before_script:
- nix-shell -p opam git pkg-config perl ppl mpfr --run 'echo Let’s go!'
- nix-shell -p opam --run 'opam init --no-setup --compiler=4.12.1'
- nix-shell -p opam --run 'opam repo add coq-released https://coq.inria.fr/opam/released'
- nix-shell -p opam git --run 'opam pin --yes --no-action add coq-mathcomp-word https://github.com/jasmin-lang/coqword.git'
- nix-shell -p opam git --run 'opam pin --yes --no-depexts --no-action add .'
- nix-shell -p opam git pkg-config perl ppl mpfr --run 'opam install --yes --no-depexts --deps-only jasmin'
script:
- >-
nix-shell -p opam ppl mpfr --run
'eval $(opam env) &&
make -j$NIX_BUILD_CORES &&
make install'
artifacts:
paths:
- $PREFIX
tarball:
stage: build
variables:
EXTRA_NIX_ARGUMENTS: --arg testDeps true
TARBALL: jasmin-compiler-$CI_COMMIT_SHORT_SHA
extends: .common
dependencies:
- coq
script:
- nix-shell --arg inCI true $EXTRA_NIX_ARGUMENTS --run 'make -C compiler dist DISTDIR=$TARBALL'
artifacts:
paths:
- compiler/$TARBALL.tgz
check:
stage: test
variables:
EXTRA_NIX_ARGUMENTS: --arg testDeps true
extends: .common
dependencies:
- coq
- ocaml
script:
- nix-shell --arg inCI true $EXTRA_NIX_ARGUMENTS --run 'make -j$NIX_BUILD_CORES -C compiler check-ci'
push-compiler-code:
stage: deploy
environment: deployment
only:
variables:
- $DEPLOY_KEY
variables:
GIT_STRATEGY: none
TARBALL: jasmin-compiler-$CI_COMMIT_SHORT_SHA
needs:
- tarball
dependencies:
- tarball
before_script:
- nix-env -iA nixpkgs.git
- nix-env -iA nixpkgs.openssh
- eval $(ssh-agent -s)
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- ssh-keyscan gitlab.com >> ~/.ssh/known_hosts
- git config --global user.name "Jasmin Contributors"
- git config --global user.email "10184778-jasmin-lang@users.noreply.gitlab.com"
script:
- echo "$DEPLOY_KEY" | tr -d '\r' | ssh-add - > /dev/null
- git clone git@gitlab.com:jasmin-lang/jasmin-compiler.git _deploy
- cd _deploy
- git checkout $CI_COMMIT_REF_NAME || git checkout --orphan $CI_COMMIT_REF_NAME
- rm -rf compiler
- tar xzvf ../compiler/$TARBALL.tgz
- mv $TARBALL/ compiler
- git add compiler
- git commit -m "Jasmin compiler on branch “$CI_COMMIT_REF_NAME” at $CI_COMMIT_SHORT_SHA" || true
- git push --set-upstream origin $CI_COMMIT_REF_NAME