template / windows / files / .gitlab-ci.yml
Branch windows · default branch · all branches
.gitlab-ci.yml
| 1 | # This file is a template, and might need editing before it works on your project. |
| 2 | # This is a sample GitLab CI/CD configuration file that should run without any modifications. |
| 3 | # It demonstrates a basic 3 stage CI/CD pipeline. Instead of real tests or scripts, |
| 4 | # it uses echo commands to simulate the pipeline execution. |
| 5 | # |
| 6 | # A pipeline is composed of independent jobs that run scripts, grouped into stages. |
| 7 | # Stages run in sequential order, but jobs within stages run in parallel. |
| 8 | # |
| 9 | # For more information, see: https://docs.gitlab.com/ee/ci/yaml/index.html#stages |
| 10 | # |
| 11 | # You can copy and paste this template into a new `.gitlab-ci.yml` file. |
| 12 | # You should not add this template to an existing `.gitlab-ci.yml` file by using the `include:` keyword. |
| 13 | # |
| 14 | # To contribute improvements to CI/CD templates, please follow the Development guide at: |
| 15 | # https://docs.gitlab.com/ee/development/cicd/templates.html |
| 16 | # This specific template is located at: |
| 17 | # https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Getting-Started.gitlab-ci.yml |
| 18 | |
| 19 | # image: golang:1.19 |
| 20 | image: mcr.microsoft.com/powershell:latest |
| 21 | |
| 22 | before_script: |
| 23 | - choco install golang |
| 24 | |
| 25 | stages: # List of stages for jobs, and their order of execution |
| 26 | - build |
| 27 | - test |
| 28 | - release |
| 29 | |
| 30 | build-job: # This job runs in the build stage, which runs first. |
| 31 | stage: build |
| 32 | script: |
| 33 | - echo "Compiling the code..." |
| 34 | - make build |
| 35 | - echo "Compile complete." |
| 36 | |
| 37 | unit-test-job: # This job runs in the test stage. |
| 38 | stage: test # It only starts when the job in the build stage completes successfully. |
| 39 | script: |
| 40 | - echo "Running unit tests... This will take about 60 seconds." |
| 41 | - make test |
| 42 | - echo "Code coverage is 90%" |
| 43 | |
| 44 | lint-test-job: # This job also runs in the test stage. |
| 45 | stage: test # It can run at the same time as unit-test-job (in parallel). |
| 46 | script: |
| 47 | - echo "Linting code... This will take about 10 seconds." |
| 48 | - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.50.1 |
| 49 | - export PATH=$PATH:./bin |
| 50 | - whereis golangci-lint |
| 51 | - golangci-lint --version |
| 52 | - make lint |
| 53 | - echo "No lint issues found." |
| 54 | |
| 55 | release: |
| 56 | stage: release |
| 57 | image: docker:stable |
| 58 | services: |
| 59 | - docker:dind |
| 60 | |
| 61 | variables: |
| 62 | # Disable shallow cloning so that goreleaser can diff between tags to |
| 63 | # generate a changelog. |
| 64 | GIT_DEPTH: 0 |
| 65 | |
| 66 | # Only run this release job for tags, not every commit (for example). |
| 67 | only: |
| 68 | refs: |
| 69 | - tags |
| 70 | |
| 71 | script: | |
| 72 | echo "$CI_JOB_STAGE" |
| 73 | echo "$GITLAB_TOKEN" |
| 74 | echo "honestly, wtf is going on?!" |
| 75 | # GITLAB_TOKEN is needed to create GitLab releases. |
| 76 | # DOCKER_* are needed to push Docker images. |
| 77 | docker run --rm --privileged \ |
| 78 | -v $PWD:/go/src/gitlab.com/YourGitLabUser/YourGitLabRepo \ |
| 79 | -w /go/src/gitlab.com/YourGitLabUser/YourGitLabRepo \ |
| 80 | -v /var/run/docker.sock:/var/run/docker.sock \ |
| 81 | -e GITLAB_TOKEN \ |
| 82 | goreleaser/goreleaser release --rm-dist |