forked from plausible/analytics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
125 lines (114 loc) · 2.79 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
include:
- template: Container-Scanning.gitlab-ci.yml
- template: License-Scanning.gitlab-ci.yml
- template: SAST.gitlab-ci.yml
stages:
- prepare
- compile
- test
- build
- postbuild
.commons: &elixir-commons
image: elixir:1.10.3
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- $CI_PROJECT_DIR/.mix
- $CI_PROJECT_DIR/priv/plts
- ~/.hex/
before_script:
- mkdir -p $CI_PROJECT_DIR/priv/plts/
- mix local.hex --force && mix local.rebar --force
- chmod +x .gitlab/build-scripts/*
- source .gitlab/build-scripts/docker.gitlab.sh
deps:
<<: *elixir-commons
stage: prepare
variables:
MIX_HOME: $CI_PROJECT_DIR/.mix
script:
- mix deps.get
dependencies: []
artifacts:
paths:
- mix.lock
- deps
compile:
<<: *elixir-commons
stage: compile
script:
- mix compile
dependencies:
- deps
artifacts:
paths:
- mix.lock
- _build
- deps
license_scanning:
stage: compile
dependencies:
- deps
sast:
stage: compile
test:ex_unit:
<<: *elixir-commons
services:
- postgres
- name: yandex/clickhouse-server:20.3.9.70
alias: clickhouse
stage: test
variables:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
DATABASE_URL: postgres://postgres:postgres@postgres:5432/plausible_test?currentSchema=default
CLICKHOUSE_DATABASE_HOST: clickhouse
CLICKHOUSE_DATABASE_NAME: plausible_test
MIX_HOME: $CI_PROJECT_DIR/.mix
before_script:
- apt update && apt install -y clickhouse-client
- clickhouse-client --host clickhouse --query "CREATE DATABASE IF NOT EXISTS plausible_test"
script:
- mix test --cover
coverage: '/\[TOTAL\]\s+(\d+\.\d+)%/'
dependencies:
- compile
artifacts:
reports:
junit: plausible-report.xml
build:docker:
<<: *elixir-commons
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
stage: build
variables:
MIX_ENV: prod
MIX_HOME: $CI_PROJECT_DIR/.mix/
APP_VERSION: $CI_COMMIT_SHORT_SHA
before_script:
- chmod +x .gitlab/build-scripts/*
- source .gitlab/build-scripts/docker.gitlab.sh
- docker_create_config
script:
- docker_build_image
dependencies:
- compile
only:
- master
deploy:plausible:
stage: postbuild
script:
- "curl -X POST -F token=$PLAUSIBLE_DEPLOY_TOKEN -F ref=master -F variables[IMAGE_TAG]=${CI_COMMIT_REF_SLUG}-${CI_COMMIT_SHORT_SHA} $PLAUSIBLE_DEPLOY_PROJECT"
only:
- master
container_scanning:
stage: postbuild
image: registry.gitlab.com/gitlab-org/security-products/analyzers/klar:$CS_MAJOR_VERSION
variables:
CS_MAJOR_VERSION: 2
KLAR_TRACE: "true"
CLAIR_TRACE: "true"
CLAIR_OUTPUT: "medium"
CI_APPLICATION_REPOSITORY: $CI_REGISTRY_IMAGE
CI_APPLICATION_TAG: ${CI_COMMIT_REF_SLUG}-$CI_COMMIT_SHORT_SHA