summaryrefslogtreecommitdiff
path: root/tiger-compiler/.gitlab-ci.yml
diff options
context:
space:
mode:
Diffstat (limited to 'tiger-compiler/.gitlab-ci.yml')
-rw-r--r--tiger-compiler/.gitlab-ci.yml188
1 files changed, 188 insertions, 0 deletions
diff --git a/tiger-compiler/.gitlab-ci.yml b/tiger-compiler/.gitlab-ci.yml
new file mode 100644
index 0000000..6b96e4e
--- /dev/null
+++ b/tiger-compiler/.gitlab-ci.yml
@@ -0,0 +1,188 @@
+image: alpine:3.21.3
+
+stages:
+ - build
+ - test
+ - deploy
+ - release
+
+.on_mr_only:
+ rules:
+ - if: $CI_PIPELINE_SOURCE == "merge_request_event"
+ when: always
+
+.connect_to_intra_git:
+ image:
+ name: alpine/git:2.47.1
+ entrypoint: [""]
+ environment:
+ name: forge-intra
+ url: https://intra.forge.epita.fr/epita-ing-assistants-yaka/tiger-2027/root/tiger-2027/
+ before_script:
+ ##
+ ## Check that all parameters are properly defined
+ ##
+ - test -n "$GIT_INTRA_REPO_URL"
+ - test -n "$GIT_INTRA_GLOBAL_URL"
+ - test -n "$GIT_DEPLOY_BRANCH"
+ - test -n "$GIT_RUNNER_NAME"
+ - test -n "$GIT_RUNNER_EMAIL"
+
+ ##
+ ## Check that ssh-agent is active. Install it and start it if it isn't yet
+ ##
+ - 'command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y )'
+ - eval $(ssh-agent -s)
+
+ ##
+ ## Add the SSH key to the known keys
+ ##
+ - chmod 400 "$SSH_PRIVATE_KEY"
+ - ssh-add "$SSH_PRIVATE_KEY"
+
+ ##
+ ## Properly setup .ssh folder if it hasn't been properly done so already
+ ##
+ - mkdir -p ~/.ssh
+ - chmod 700 ~/.ssh
+
+ ##
+ ## Add the host (Git repo server) to known hosts
+ ##
+ - ssh-keyscan -v -H $GIT_INTRA_GLOBAL_URL >> ~/.ssh/known_hosts
+ - chmod 644 ~/.ssh/known_hosts
+
+ ##
+ ## Test connection. Stop job on failure
+ ##
+ - ssh -T git@"$GIT_INTRA_GLOBAL_URL"
+
+ ##
+ ## Set Git credentials
+ ##
+ - git config --global user.email "$RUNNER_GIT_EMAIL"
+ - git config --global user.name "$RUNNER_GIT_NAME"
+
+# clang-format-job:
+# extends: .on_mr_only
+# stage: build
+# allow_failure: true
+# before_script:
+# - apk update && apk add --no-cache clang-extra-tools
+# - clang-format --version
+# script:
+# - find src lib -type f '(' -name '*.c?' -o -name '*.h*' ')' | xargs clang-format --Werror --dry-run
+
+# clang-tidy-job:
+# extends: .on_mr_only
+# stage: build
+# allow_failure: true
+# before_script:
+# - apk update && apk add --no-cache clang-extra-tools
+# - clang-tidy --version
+# script:
+# # TODO: improve command (this one works but is slow)
+# - find src -type f -a -name "*.cc" -exec clang-tidy {} --extra-arg=-std=c++20 -- -Isrc -Ilib \;
+
+compilation-job:
+ extends: .on_mr_only
+ stage: build
+ image: registry.cri.epita.fr/martial.simon/tiger-compiler/buildenv-slim:1.1.0
+ before_script:
+ - gcc --version
+ - make --version
+ - autoreconf --version
+ script:
+ - ./bootstrap
+ - ./configure
+ - make -j
+ artifacts:
+ paths:
+ - src/tc
+ expire_in: 7 days
+
+testing-job:
+ extends: .on_mr_only
+ stage: test
+ image: registry.cri.epita.fr/martial.simon/tiger-compiler/buildenv-slim:1.1.0-pytest
+ dependencies:
+ - compilation-job
+ before_script:
+ - pytest --version
+ script:
+ - cd tests/python
+ - CI=1 pytest
+
+push-master-state-to-intra-job:
+ extends: .connect_to_intra_git
+ stage: deploy
+ rules:
+ - if: $CI_COMMIT_BRANCH == "master" && $CI_PIPELINE_SOURCE == "push"
+ when: always
+ script:
+ ##
+ ## Check connection to Git repo before trying to push into it
+ ##
+ - git ls-remote --exit-code -h "$GIT_INTRA_REPO_URL" || { [ $? -ne 2 ] && return 1; }
+
+ ##
+ ## Get intra repo reference
+ ##
+ - git remote | grep 'intra' || git remote add intra "$GIT_INTRA_REPO_URL"
+ - git remote update
+
+ ##
+ ## Debug dumping
+ ##
+ - git log --all --oneline --graph --decorate
+
+ ##
+ ## Push
+ ##
+ - git push intra HEAD:"$GIT_DEPLOY_BRANCH"
+
+push-tag-to-intra-job:
+ extends: .connect_to_intra_git
+ stage: deploy
+ rules:
+ - if: >
+ $CI_COMMIT_TAG != null
+ && ($CI_COMMIT_TAG =~ "/^bonus-dementor-tc\w+.*$/"
+ || $CI_COMMIT_TAG =~ "/^dementor-tc\w+.*$/"
+ || $CI_COMMIT_TAG =~ "/^tc\w+.*$/")
+ when: always
+ script:
+ ##
+ ## Check connection to Git repo before trying to push into it
+ ##
+ - git ls-remote --exit-code -h "$GIT_INTRA_REPO_URL" || { [ $? -ne 2 ] && return 1; }
+
+ ##
+ ## Get intra repo reference
+ ##
+ - git remote | grep 'intra' || git remote add intra "$GIT_INTRA_REPO_URL"
+ - git remote update
+
+ ##
+ ## Debug dumping
+ ##
+ - git log --all --oneline --graph --decorate
+
+ ##
+ ## Push tag
+ ##
+ - git push intra "$CI_COMMIT_TAG"
+
+release-job:
+ stage: release
+ image: registry.gitlab.com/gitlab-org/release-cli:latest
+ rules:
+ - if: $CI_COMMIT_TAG != null
+ needs:
+ - job: push-tag-to-intra-job
+ artifacts: false
+ script:
+ - echo "creating a new release for tag $CI_COMMIT_TAG..."
+ release: # See https://docs.gitlab.com/ee/ci/yaml/#release for available properties
+ tag_name: '$CI_COMMIT_TAG'
+ description: '$CI_COMMIT_TAG'