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 fi
55
56test:up-to-date-prisma-schema:
57 image: registry.inpt.fr/inp-net/images/go-just:1.23.5-1.39.0
58 stage: test
59 rules:
60 - when: always
61 before_script:
62 - apk add curl
63 - just updateschema
64 - cp schema.prisma original_schema.prisma
65 script:
66 - |
67 if ! diff -q schema.prisma original_schema.prisma; then
68 echo "Generated schema.prisma is different from original, please run 'just updateschema' and commit the changes"
69 exit 1
70 fi
71
72.gitops:
73 image: registry.inpt.fr/inp-net/images/go-just:1.23.5-1.39.0
74 before_script:
75 - git config --global user.name gitlab
76 - git config --global user.email "git@noreply.inpt.fr"
77 - git remote remove gitlab_origin || true
78 - git remote add gitlab_origin https://bot:$BOT_TOKEN@$CI_SERVER_SHELL_SSH_HOST/$CI_PROJECT_PATH
79
80update:prisma-schema:
81 extends: .gitops
82 stage: update
83 allow_failure: true
84 rules:
85 - if: $CI_PIPELINE_SOURCE == "pipeline"
86 - when: manual
87 script:
88 - apk add curl
89 - just updateschema $SCHEMA_RAW_URL
90 - git add schema.prisma
91 - 'git commit -m "chore(prisma): update schema.prisma after churros/churros change [ci release]"'
92 - git push gitlab_origin HEAD:main
93
94release-after-prisma-schema-update:
95 extends: .gitops
96 stage: build
97 rules:
98 - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_COMMIT_TITLE =~ /\[ci release]/
99 script:
100 - git fetch --tags
101 - latest_tag=$(git tag -l --sort=-v:refname | head -n 1)
102 - git tag $(echo $latest_tag | awk -F. '{OFS="."; $NF+=1; print $0}')
103 - git push gitlab_origin --tags
104
105
106build:
107 extends: .buildkit
108 stage: build
109 rules:
110 - if: $CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+/
111 variables:
112 DEPLOY: "true"
113 script:
114 - |
115 if [ "$DEPLOY" == "true" ]; then
116 export TAG=$(echo $CI_COMMIT_TAG | sed 's/^v//')
117 else
118 export TAG=latest-$(echo $CI_COMMIT_SHA | cut -c-6)
119 fi
120 - |
121 buildctl-daemonless.sh build \
122 --frontend=dockerfile.v0 \
123 --local context=. \
124 --local dockerfile=. \
125 --opt build-arg:TAG=$TAG \
126 --output type=image,name=$CI_REGISTRY_IMAGE:v$TAG,push=$DEPLOY
127 - |
128 if [ "$DEPLOY" == "true"]; then
129 echo "Successfully built and pushed $CI_REGISTRY_IMAGE:v$TAG"
130 else
131 echo "Successfully built $CI_REGISTRY_IMAGE:v$TAG"
132 fi