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