This repository has no description
1.buildkit:
2 image:
3 name: moby/buildkit:rootless
4 entrypoint: ["sh", "-c"]
5 variables:
6 BUILDKITD_FLAGS: --oci-worker-no-process-sandbox
7 before_script:
8 - |
9 mkdir -p ~/.docker && cat > ~/.docker/config.json <<EOF
10 {
11 "auths": {
12 "$CI_REGISTRY": {
13 "auth": "$(echo -n "$CI_REGISTRY_USER:$CI_REGISTRY_PASSWORD" | base64)"
14 }
15 }
16 }
17 EOF
18
19stages:
20 - update
21 - test
22 - build
23
24test:typescript:
25 image: registry.inpt.fr/inp-net/images/go-just:1.23.5-1.39.0
26 stage: test
27 rules:
28 - when: always
29 before_script:
30 - apk add git npm jq
31 - cp -r typescript typescript_original
32 - just build
33 - just gen_typescript
34 script:
35 - |
36 for file in typescript/*.ts; do
37 if ! diff -q $file typescript_original/$(basename $file); then
38 diff typescript_original/$(basename $file) $file
39 echo "Generated file $file is different from original, please run 'just gen_typescript' and commit the changes"
40 exit 1
41 fi
42 done
43 - |
44 mkdir -p testarea; cd testarea
45 npm init -y
46 jq '.type = "module"' < package.json > package.json.new
47 mv package.json.new package.json
48 npm add -S git+$CI_PROJECT_URL#$CI_COMMIT_HASH
49 echo "import * as notella from '@inp-net/notella'; console.log(notella)" > index.js
50 node index.js > lib.txt
51 if ! diff -q lib.txt ../typescript/lib.txt; then
52 diff lib.txt ../typescript/lib.txt
53 echo Runtime library has different values, re-run just gen_typescript and commit the changes
54 exit 1
55 fi
56
57test:up-to-date-prisma-schema:
58 image: registry.inpt.fr/inp-net/images/go-just:1.23.5-1.39.0
59 stage: test
60 rules:
61 - when: always
62 before_script:
63 - apk add curl
64 - just updateschema
65 - cp schema.prisma original_schema.prisma
66 script:
67 - |
68 if ! diff -q schema.prisma original_schema.prisma; then
69 echo "Generated schema.prisma is different from original, please run 'just updateschema' and commit the changes"
70 exit 1
71 fi
72
73.gitops:
74 image: registry.inpt.fr/inp-net/images/go-just:1.23.5-1.39.0
75 before_script:
76 - git config --global user.name gitlab
77 - git config --global user.email "git@noreply.inpt.fr"
78 - git remote remove gitlab_origin || true
79 - git remote add gitlab_origin https://bot:$BOT_TOKEN@$CI_SERVER_SHELL_SSH_HOST/$CI_PROJECT_PATH
80
81update:prisma-schema:
82 extends: .gitops
83 stage: update
84 allow_failure: true
85 rules:
86 - if: $CI_PIPELINE_SOURCE == "pipeline"
87 - when: manual
88 script:
89 - apk add curl
90 - just updateschema $SCHEMA_RAW_URL
91 - git add schema.prisma
92 - 'git commit -m "chore(prisma): update schema.prisma after churros/churros change [ci release]"'
93 - git push gitlab_origin HEAD:main
94
95release-after-prisma-schema-update:
96 extends: .gitops
97 stage: build
98 rules:
99 - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_COMMIT_TITLE =~ /\[ci release]/
100 script:
101 - git fetch --tags
102 - latest_tag=$(git tag -l --sort=-v:refname | head -n 1)
103 - git tag $(echo $latest_tag | awk -F. '{OFS="."; $NF+=1; print $0}')
104 - git push gitlab_origin --tags
105
106
107build:
108 extends: .buildkit
109 stage: build
110 rules:
111 - if: $CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+/
112 variables:
113 DEPLOY: "true"
114 script:
115 - |
116 if [ "$DEPLOY" == "true" ]; then
117 export TAG=$(echo $CI_COMMIT_TAG | sed 's/^v//')
118 else
119 export TAG=latest-$(echo $CI_COMMIT_SHA | cut -c-6)
120 fi
121 - |
122 buildctl-daemonless.sh build \
123 --frontend=dockerfile.v0 \
124 --local context=. \
125 --local dockerfile=. \
126 --opt build-arg:TAG=$TAG \
127 --output type=image,name=$CI_REGISTRY_IMAGE:v$TAG,push=$DEPLOY
128 - |
129 if [ "$DEPLOY" == "true"]; then
130 echo "Successfully built and pushed $CI_REGISTRY_IMAGE:v$TAG"
131 else
132 echo "Successfully built $CI_REGISTRY_IMAGE:v$TAG"
133 fi