From 8c4e6a85b3356291eef843e8a05e262f30531aa8 Mon Sep 17 00:00:00 2001 From: James Addison Date: Fri, 29 Oct 2021 12:16:45 +0100 Subject: [PATCH] Add .gitlab-ci.yml-compatible continuous integration configuration (#17844) * Add .gitlab-ci.collabora.yml continuous integration configuration * Relocate custom GitLab CI/CD configuration file to 'contrib' directory * Fixup: .gitlab-ci.collabora.yml -> .gitlab-ci.yml Co-authored-by: Mattermod --- build/contrib/gitlab/.gitlab-ci.yml | 61 +++++++++++++++++++++++++++++ build/contrib/gitlab/README.md | 7 ++++ 2 files changed, 68 insertions(+) create mode 100644 build/contrib/gitlab/.gitlab-ci.yml create mode 100644 build/contrib/gitlab/README.md diff --git a/build/contrib/gitlab/.gitlab-ci.yml b/build/contrib/gitlab/.gitlab-ci.yml new file mode 100644 index 0000000000..4c010e726b --- /dev/null +++ b/build/contrib/gitlab/.gitlab-ci.yml @@ -0,0 +1,61 @@ +lint: + allow_failure: true + image: golangci/golangci-lint + script: + - GO111MODULE=off GOBIN=$PWD/bin go get -u github.com/mattermost/mattermost-govet + - make config-reset + - make check-style + +test-quick: + image: docker + variables: + DOCKER_HOST: tcp://docker:2375 + DOCKER_TLS_CERTDIR: "" + TEST_DATABASE_MYSQL_DSN: "mmuser:mostest@tcp(mysql:3306)/mattermost_test?charset=utf8mb4,utf8&readTimeout=30s&writeTimeout=30s&multiStatements=true" + TEST_DATABASE_POSTGRESQL_DSN: "postgres://mmuser:mostest@postgres:5432/mattermost_test?sslmode=disable&connect_timeout=10" + TEST_DATABASE_MYSQL_ROOT_PASSWD: "mostest" + services: + - docker:dind + before_script: + - apk add --no-cache bash docker-compose go make + - make start-docker + script: + - docker run + --env MM_NO_DOCKER=true + --env-file "build/dotenv/test.env" + --mount "type=bind,source=$PWD,target=$PWD" + --network "$CI_PROJECT_NAME"_mm-test + docker + /bin/sh -c " + cd $PWD; + apk add --no-cache bash docker-compose go mailcap make; + make test-server-quick; + " + +test-full: + rules: + - if: '$CI_COMMIT_REF_NAME == "master"' + image: docker + variables: + DOCKER_HOST: tcp://docker:2375 + DOCKER_TLS_CERTDIR: "" + TEST_DATABASE_MYSQL_DSN: "mmuser:mostest@tcp(mysql:3306)/mattermost_test?charset=utf8mb4,utf8&readTimeout=30s&writeTimeout=30s&multiStatements=true" + TEST_DATABASE_POSTGRESQL_DSN: "postgres://mmuser:mostest@postgres:5432/mattermost_test?sslmode=disable&connect_timeout=10" + TEST_DATABASE_MYSQL_ROOT_PASSWD: "mostest" + services: + - docker:dind + before_script: + - apk add --no-cache bash docker-compose go make + - make start-docker + script: + - docker run + --env MM_NO_DOCKER=true + --env-file "build/dotenv/test.env" + --mount "type=bind,source=$PWD,target=$PWD" + --network "$CI_PROJECT_NAME"_mm-test + docker + /bin/sh -c " + cd $PWD; + apk add --no-cache bash docker-compose go mailcap make; + make test-server; + " diff --git a/build/contrib/gitlab/README.md b/build/contrib/gitlab/README.md new file mode 100644 index 0000000000..f94e7b5fe9 --- /dev/null +++ b/build/contrib/gitlab/README.md @@ -0,0 +1,7 @@ +# GitLab CI/CD configuration for Mattermost + +The [.gitlab-ci.yml](./.gitlab-ci.yml) file in this directory provides a [GitLab CI/CD configuration file](https://docs.gitlab.com/ee/ci/yaml/gitlab_ci_yaml.html) that can be used to run linting and unit testing for the Mattermost application. + +## Usage + +To configure your GitLab instance to use this configuration file (and without having to move it to the base directory in this git repository), you can configure the [`CI_CONFIG_PATH` predefined variable](https://docs.gitlab.com/ee/ci/variables/predefined_variables.html) for the repository in GitLab with the configuration file path (`build/contrib/gitlab/.gitlab-ci.yml`).