From 438bfd35c9301035e5770ed23d66f917227eb44f Mon Sep 17 00:00:00 2001 From: Yinebeb Tariku <84726535+yinebebt@users.noreply.github.com> Date: Thu, 15 Aug 2024 12:41:59 +0300 Subject: [PATCH 1/2] CircleCI Commit --- .circleci/config.yml | 78 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..0f74bfb --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,78 @@ +# This config was automatically generated from your source code +# Stacks detected: artifact:go-executable:,cicd:github-actions:.github/workflows,deps:go:. +version: 2.1 +jobs: + test-go: + # Install go modules and run tests + docker: + - image: cimg/go:1.20 + steps: + - checkout + - restore_cache: + key: go-mod-{{ checksum "go.sum" }} + - run: + name: Download Go modules + command: go mod download + - run: + name: Print go mod help instructions + command: "echo \"go mod download will fail if you have private repositories \nOne way to fix this for private go modules that are hosted in github:\n 1. Add a GITHUB_TOKEN and GITHUB_USER to an org context. Please refer to https://circleci.com/docs/contexts/ for more informaiton on how to use contexts.\n 2. Add a .circleci/config.yml to your repository or use this config.yml as a starting template\n 3. Configure the jobs to use the newly created context which includes GITHUB_TOKEN and GITHUB_USER \n 4. Before downloading the modules you will need to add a step to execute \\\"go env -w GOPRIVATE=github.com/\\\". \n\tThis allows go mod to install private repos under OrgNameHere.\n 5. You will also need to run \\\"git config --global url.\\\"https://$GITHUB_USER:$GITHUB_TOKEN@github.com//\\\".insteadOf \\\"https://github.com//\\\"\\\"\n 6. Finally include the \\\"go mod download\\\" it should be able to fetch your private libraries now. \nFor gitlab private go modules, follow the same instructions as above but include your GITLAB_TOKEN and GITLAB_USER.\nThen use gitlab.com instead of github.com in steps 4 and 5.\nSee https://go.dev/ref/mod#private-modules for more details.\"" + when: on_fail + - save_cache: + key: go-mod-{{ checksum "go.sum" }} + paths: + - /home/circleci/go/pkg/mod + - run: + name: Run tests + command: gotestsum --junitfile junit.xml + - store_test_results: + path: junit.xml + build-go-executables: + # Build go executables and store them as artifacts + docker: + - image: cimg/go:1.20 + steps: + - checkout + - restore_cache: + key: go-mod-{{ checksum "go.sum" }} + - run: + name: Download Go modules + command: go mod download + - run: + name: Print go mod help instructions + command: "echo \"go mod download will fail if you have private repositories \nOne way to fix this for private go modules that are hosted in github:\n 1. Add a GITHUB_TOKEN and GITHUB_USER to an org context. Please refer to https://circleci.com/docs/contexts/ for more informaiton on how to use contexts.\n 2. Add a .circleci/config.yml to your repository or use this config.yml as a starting template\n 3. Configure the jobs to use the newly created context which includes GITHUB_TOKEN and GITHUB_USER \n 4. Before downloading the modules you will need to add a step to execute \\\"go env -w GOPRIVATE=github.com/\\\". \n\tThis allows go mod to install private repos under OrgNameHere.\n 5. You will also need to run \\\"git config --global url.\\\"https://$GITHUB_USER:$GITHUB_TOKEN@github.com//\\\".insteadOf \\\"https://github.com//\\\"\\\"\n 6. Finally include the \\\"go mod download\\\" it should be able to fetch your private libraries now. \nFor gitlab private go modules, follow the same instructions as above but include your GITLAB_TOKEN and GITLAB_USER.\nThen use gitlab.com instead of github.com in steps 4 and 5.\nSee https://go.dev/ref/mod#private-modules for more details.\"" + when: on_fail + - save_cache: + key: go-mod-{{ checksum "go.sum" }} + paths: + - /home/circleci/go/pkg/mod + - run: + name: Create the ~/artifacts directory if it doesn't exist + command: mkdir -p ~/artifacts + - run: + name: Build executables + command: go build -o ~/artifacts ./... + - store_artifacts: + path: ~/artifacts + destination: executables + deploy: + # This is an example deploy job, not actually used by the workflow + docker: + - image: cimg/base:stable + steps: + # Replace this with steps to deploy to users + - run: + name: deploy + command: '#e.g. ./deploy.sh' + - run: + name: found github actions config + command: ':' +workflows: + build-and-test: + jobs: + - test-go + - build-go-executables: + requires: + - test-go + # - deploy: + # requires: + # - build-go-executables From d336b2746671b6a829e2d96486b72484cca7d62f Mon Sep 17 00:00:00 2001 From: Yinebeb-01 Date: Thu, 15 Aug 2024 13:13:27 +0300 Subject: [PATCH 2/2] fix: remove onfail runner from cirlceCI config --- .circleci/config.yml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 0f74bfb..b39bd28 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,5 +1,3 @@ -# This config was automatically generated from your source code -# Stacks detected: artifact:go-executable:,cicd:github-actions:.github/workflows,deps:go:. version: 2.1 jobs: test-go: @@ -13,10 +11,6 @@ jobs: - run: name: Download Go modules command: go mod download - - run: - name: Print go mod help instructions - command: "echo \"go mod download will fail if you have private repositories \nOne way to fix this for private go modules that are hosted in github:\n 1. Add a GITHUB_TOKEN and GITHUB_USER to an org context. Please refer to https://circleci.com/docs/contexts/ for more informaiton on how to use contexts.\n 2. Add a .circleci/config.yml to your repository or use this config.yml as a starting template\n 3. Configure the jobs to use the newly created context which includes GITHUB_TOKEN and GITHUB_USER \n 4. Before downloading the modules you will need to add a step to execute \\\"go env -w GOPRIVATE=github.com/\\\". \n\tThis allows go mod to install private repos under OrgNameHere.\n 5. You will also need to run \\\"git config --global url.\\\"https://$GITHUB_USER:$GITHUB_TOKEN@github.com//\\\".insteadOf \\\"https://github.com//\\\"\\\"\n 6. Finally include the \\\"go mod download\\\" it should be able to fetch your private libraries now. \nFor gitlab private go modules, follow the same instructions as above but include your GITLAB_TOKEN and GITLAB_USER.\nThen use gitlab.com instead of github.com in steps 4 and 5.\nSee https://go.dev/ref/mod#private-modules for more details.\"" - when: on_fail - save_cache: key: go-mod-{{ checksum "go.sum" }} paths: @@ -37,10 +31,6 @@ jobs: - run: name: Download Go modules command: go mod download - - run: - name: Print go mod help instructions - command: "echo \"go mod download will fail if you have private repositories \nOne way to fix this for private go modules that are hosted in github:\n 1. Add a GITHUB_TOKEN and GITHUB_USER to an org context. Please refer to https://circleci.com/docs/contexts/ for more informaiton on how to use contexts.\n 2. Add a .circleci/config.yml to your repository or use this config.yml as a starting template\n 3. Configure the jobs to use the newly created context which includes GITHUB_TOKEN and GITHUB_USER \n 4. Before downloading the modules you will need to add a step to execute \\\"go env -w GOPRIVATE=github.com/\\\". \n\tThis allows go mod to install private repos under OrgNameHere.\n 5. You will also need to run \\\"git config --global url.\\\"https://$GITHUB_USER:$GITHUB_TOKEN@github.com//\\\".insteadOf \\\"https://github.com//\\\"\\\"\n 6. Finally include the \\\"go mod download\\\" it should be able to fetch your private libraries now. \nFor gitlab private go modules, follow the same instructions as above but include your GITLAB_TOKEN and GITLAB_USER.\nThen use gitlab.com instead of github.com in steps 4 and 5.\nSee https://go.dev/ref/mod#private-modules for more details.\"" - when: on_fail - save_cache: key: go-mod-{{ checksum "go.sum" }} paths: