-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
66 lines (66 loc) · 2.44 KB
/
.gitlab-ci.yml
File metadata and controls
66 lines (66 loc) · 2.44 KB
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
# You can override the included template(s) by including variable overrides
# SAST customization: https://docs.gitlab.com/ee/user/application_security/sast/#customizing-the-sast-settings
# Secret Detection customization: https://docs.gitlab.com/ee/user/application_security/secret_detection/pipeline/#customization
# Dependency Scanning customization: https://docs.gitlab.com/ee/user/application_security/dependency_scanning/#customizing-the-dependency-scanning-settings
# Container Scanning customization: https://docs.gitlab.com/ee/user/application_security/container_scanning/#customizing-the-container-scanning-settings
# Note that environment variables can be set in several places
# See https://docs.gitlab.com/ee/ci/variables/#cicd-variable-precedence
stages:
- format
- test
black-format:
stage: format
image: python:3.12
script:
- pip install black
- black --line-length 120 --target-version py312 .
- |
if [ -n "$(git status --porcelain)" ]; then
mkdir -p ~/.ssh
echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
git config user.name "GitLab CI/CD"
git config user.email "gitlab-ci@example.com"
git add .
git commit -m "Format code using Black"
git push git@gitlab.com:themastercollection/thestudentmaster.git HEAD:$CI_COMMIT_REF_NAME
else
echo "No changes to commit. Code is already formatted correctly."
fi
rules:
- changes:
- "**/*.py"
prettier-format:
stage: format
image: node:lts
script:
- npm install --global prettier
- prettier "!.gitlab-ci.yml" --write "**/*.{js,jsx,ts,tsx,json,css,scss,md,yml}"
- |
if [ -n "$(git status --porcelain)" ]; then
mkdir -p ~/.ssh
echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
git config user.name "GitLab CI/CD"
git config user.email "gitlab-ci@example.com"
git add .
git commit -m "Format code using Prettier"
git push git@gitlab.com:themastercollection/thestudentmaster.git HEAD:$CI_COMMIT_REF_NAME
else
echo "No changes to commit. Code is already formatted correctly."
fi
rules:
- changes:
- "**/*.{js,jsx,ts,tsx,json,css,scss,md,yml}"
test:
stage: test
script:
- echo "Running tests..."
- sleep 1
- echo "Tests passed!"
sast:
stage: test
include:
- template: Security/SAST.gitlab-ci.yml