Skip to content

Commit

Permalink
ci(circleci): cleanup circleci configuration and scripts (#10908)
Browse files Browse the repository at this point in the history
* ci(circleci): remove circle CI configuration
* ci(circleci): replace build badge with GHA badge
* ci(circleci): remove circle ci directives in e2e.yaml workflow
* ci(circleci): remove circle ci in doc
---------

Signed-off-by: Jay Chen <[email protected]>
  • Loading branch information
jijiechen authored and kumahq[bot] committed Aug 7, 2024
1 parent 0978f93 commit c822771
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 869 deletions.
636 changes: 0 additions & 636 deletions .circleci/config.yml

This file was deleted.

1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
.circleci
.github
.gitignore
.gitmodules
Expand Down
241 changes: 15 additions & 226 deletions .github/workflows/_e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,42 +29,28 @@ jobs:
matrix:
parallelRunnerId: ${{ fromJSON((fromJSON(inputs.matrix).parallelism == '4' && '[0, 1, 2, 3]') || '[0]') }}
steps:
- name: "Print parameters"
id: eval-params
run: |
RUN_TYPE=""
RUNNER="${{ fromJSON(inputs.runnersByArch)[env.E2E_PARAM_ARCH] }}"
if [[ "$RUNNER" == "circleci" ]]; then
RUN_TYPE="circleci"
elif [[ "$RUNNER" != "" ]]; then
RUN_TYPE="github"
fi
echo "Running with: ${{ toJSON(inputs) }} ${{ toJSON(env) }}"
echo "run-type=$RUN_TYPE">> $GITHUB_OUTPUT
- name: "GitHub Actions: check out code"
if: steps.eval-params.outputs.run-type == 'github'
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 0
<<<<<<< HEAD
- name: "GitHub Actions: setup go"
if: steps.eval-params.outputs.run-type == 'github'
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
=======
- uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
>>>>>>> e780588b9 (ci(circleci): cleanup circleci configuration and scripts (#10908))
with:
go-version-file: go.mod
- name: "GitHub Actions: set up cache"
if: steps.eval-params.outputs.run-type == 'github'
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
- uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: |
${{ env.CI_TOOLS_DIR }}
key: ${{ runner.os }}-${{ runner.arch }}-devtools-${{ hashFiles('mk/dependencies/deps.lock') }}
restore-keys: |
${{ runner.os }}-${{ runner.arch }}-devtools
- if: steps.eval-params.outputs.run-type == 'github'
run: |
- run: |
make dev/tools
- name: "Github Actions: Free up disk space for the Runner"
if: steps.eval-params.outputs.run-type == 'github'
- name: "Free up disk space for the Runner"
run: |
echo "Disk usage before cleanup"
sudo df -h
Expand All @@ -74,25 +60,17 @@ jobs:
docker system prune --all -f
echo "Disk usage after cleanup"
sudo df -h
- name: "Github Actions: build"
if: steps.eval-params.outputs.run-type == 'github'
run: |
- run: |
make build
- name: "Github Actions: distributions"
if: steps.eval-params.outputs.run-type == 'github'
run: |
- run: |
make -j build/distributions
- name: "Github Actions: images"
if: steps.eval-params.outputs.run-type == 'github'
run: |
- run: |
make -j images
make -j docker/save
- name: "GitHub Actions: setup helm"
if: steps.eval-params.outputs.run-type == 'github'
run: |
- run: |
make dev/set-kuma-helm-repo
- name: "GitHub Actions: enable ipv6 for docker"
if: ${{ steps.eval-params.outputs.run-type == 'github' && env.E2E_PARAM_K8S_VERSION == 'kindIpv6' }}
- name: "Enable ipv6 for docker"
if: ${{ env.E2E_PARAM_K8S_VERSION == 'kindIpv6' }}
run: |
cat <<'EOF' | sudo tee /etc/docker/daemon.json
{
Expand All @@ -103,8 +81,7 @@ jobs:
}
EOF
sudo service docker restart
- name: "GitHub Actions: run E2E tests"
if: steps.eval-params.outputs.run-type == 'github'
- name: "Run E2E tests"
run: |
if [[ "${{ env.E2E_PARAM_K8S_VERSION }}" == "kindIpv6" ]]; then
export IPV6=true
Expand Down Expand Up @@ -147,191 +124,3 @@ jobs:
path: |
/tmp/e2e-debug/
retention-days: ${{ github.event_name == 'pull_request' && 1 || 30 }}
- name: "CircleCI: make circleci parameters"
if: steps.eval-params.outputs.run-type == 'circleci'
id: circleci-gen-params
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
let circleCIParams = {
'gh_action_build_artifact_name': 'build-output',
'gh_action_run_id': '${{ github.run_id }}'
};
let inputs = JSON.parse(${{ toJSON(inputs.matrix) }});
Object.keys(inputs).forEach(function(key) {
circleCIParams[`e2e_param_${key}`] = inputs[key];
});
let circleCIBody = {
"parameters": circleCIParams,
};
if ( "${{ github.event_name }}" == "pull_request" ) {
circleCIBody["branch"] = 'pull/${{ github.event.pull_request.number }}/merge';
} else {
circleCIBody["tag"] = '${{ github.sha }}'
}
core.info(`created request object for circleCI ${JSON.stringify(circleCIBody)}`);
return circleCIBody
- name: "CircleCI: trigger a new pipeline workflow on CircleCI"
if: steps.eval-params.outputs.run-type == 'circleci'
id: circle-ci-trigger
run: |
# Trigger CircleCI manually, reference: https://github.com/CircleCI-Public/trigger-circleci-pipeline-action/blob/main/src/lib/CircleCIPipelineTrigger.ts#L82
set -e
if [ "${{ runner.debug }}" == "1" ]; then
set -x
fi
CIRCLE_CI_API_PATH=https://circleci.com/api/v2/project/gh/${{ github.repository }}/pipeline
echo "Calling CircleCI api with parameters:
URL: $CIRCLE_CI_API_PATH
BODY: ${{ steps.circleci-gen-params.outputs.result }}"
if [ "${{ secrets.CIRCLECI_TOKEN }}" == "" ]; then
echo "Skipping request CircleCI because secret 'CIRCLECI_TOKEN' not set."
exit 0
fi
function request(){
METHOD=$1
URL=$2
DATA=$3
if [ "$DATA" != "" ]; then
DATA="--data $DATA"
fi
OUTPUT_FILE=/tmp/circleci-response-$RANDOM.json
touch $OUTPUT_FILE
STATUS_CODE=
while [[ "$STATUS_CODE" == "" ]]; do
STATUS_CODE=$(curl -o $OUTPUT_FILE -sL -w "%{http_code}" -X $METHOD $URL \
--header "content-type: application/json" --header "accept: application/json" \
--header "x-attribution-login: ${{ github.actor }}" --header "x-attribution-actor-id: ${{ github.actor }}" \
--header "Circle-Token: ${{ secrets.CIRCLECI_TOKEN }}" $DATA )
if [[ "$STATUS_CODE" == "429" ]]; then
STATUS_CODE=
echo '' > $OUTPUT_FILE
sleep $((RANDOM % 3))
fi
done
if [ $STATUS_CODE -lt 200 ] || [ $STATUS_CODE -gt 399 ] ; then
echo "Error requesting $METHOD $URL (status $STATUS_CODE)"
cat $OUTPUT_FILE
fi
cat $OUTPUT_FILE
rm $OUTPUT_FILE
}
PIPELINE_ID=$(request POST $CIRCLE_CI_API_PATH '${{ steps.circleci-gen-params.outputs.result }}' | tr '\n' ' ' | jq -Rrc 'fromjson | .id')
sleep 3
WORKFLOW_DETAILS=$(request GET https://circleci.com/api/v2/pipeline/$PIPELINE_ID/workflow | tr '\n' ' ' | jq -Rrc 'fromjson | .items[] | select(.name == "manual-e2e")')
PIPELINE_NUMBER=$(echo $WORKFLOW_DETAILS | tr '\n' ' ' | jq -Rrc 'fromjson | .pipeline_number')
WORKFLOW_ID=$(echo $WORKFLOW_DETAILS | tr '\n' ' ' | jq -Rrc 'fromjson | .id')
echo "pipeline_number=$PIPELINE_NUMBER" >> $GITHUB_OUTPUT
echo "workflow_id=$WORKFLOW_ID" >> $GITHUB_OUTPUT
if [[ "$WORKFLOW_ID" == "" ]]; then
echo "Could not trigger a workflow on CircleCI, check your .circleci/config.yaml"
exit 1
fi
echo ''
echo "CircleCI pipeline triggered successfully, pipeline id: $PIPELINE_ID"
echo "Check CircleCI workflow details at: https://app.circleci.com/pipelines/gh/${{ github.repository }}/$PIPELINE_NUMBER/workflows/$WORKFLOW_ID"
- name: "CircleCI: check run status of pipeline workflow on CircleCI"
if: ${{ steps.eval-params.outputs.run-type == 'circleci' && steps.circle-ci-trigger.outputs.workflow_id != '' }}
run: |
set -e
if [ "${{ runner.debug }}" == "1" ]; then
set -x
fi
function request(){
METHOD=$1
URL=$2
DATA=$3
if [ "$DATA" != "" ]; then
DATA="--data $DATA"
fi
OUTPUT_FILE=/tmp/circleci-response-$RANDOM.json
touch $OUTPUT_FILE
STATUS_CODE=$(curl -o $OUTPUT_FILE -sL -w "%{http_code}" -X $METHOD $URL \
--header "content-type: application/json" --header "accept: application/json" \
--header "x-attribution-login: ${{ github.actor }}" --header "x-attribution-actor-id: ${{ github.actor }}" \
--header "Circle-Token: ${{ secrets.CIRCLECI_TOKEN }}" $DATA )
if [ "$STATUS_CODE" == "429" ]; then
# we are exceeding rate limit, try again later
echo '{"status": ""}'
return
fi
if [ $STATUS_CODE -lt 200 ] || [ $STATUS_CODE -gt 399 ] ; then
echo "Error requesting $METHOD $URL (status $STATUS_CODE)"
cat $OUTPUT_FILE
fi
cat $OUTPUT_FILE
rm $OUTPUT_FILE
}
function check_workflow(){
WORKFLOW_ID=$1
STATUS=''
# status could be "success" "running" "not_run" "failed" "error" "failing" "on_hold" "canceled" "unauthorized"
# statuses to continue: "running" "on_hold"
# status completed: "success" "not_run" "failed" "error" "failing" "canceled" "unauthorized"
while [[ "$STATUS" == "" ]] || [[ "$STATUS" == "running" ]] || [[ "$STATUS" == "on_hold" ]]; do
sleep $((RANDOM % 5 + 25))
STATUS=$(request GET https://circleci.com/api/v2/workflow/$WORKFLOW_ID | tr '\n' ' ' | jq -Rrc 'fromjson | .status')
echo -n .
done
echo ''
if [[ "$STATUS" == "success" ]]; then
echo "CircleCI workflow has completed successfully."
exit 0
else
echo "CircleCI workflow has completed with status: '$STATUS'."
exit 1
fi
}
PIPELINE_NUMBER='${{ steps.circle-ci-trigger.outputs.pipeline_number }}'
WORKFLOW_ID='${{ steps.circle-ci-trigger.outputs.workflow_id }}'
echo "Check CircleCI workflow details at: https://app.circleci.com/pipelines/gh/${{ github.repository }}/$PIPELINE_NUMBER/workflows/$WORKFLOW_ID"
echo "Tracking workflow status:"
check_workflow '${{ steps.circle-ci-trigger.outputs.workflow_id }}'
- name: "CircleCI: cancel CircleCI running if requested"
if: ${{ steps.eval-params.outputs.run-type == 'circleci' && cancelled() && steps.circle-ci-trigger.outputs.workflow_id != '' }}
run: |
set -e
if [ "${{ runner.debug }}" == "1" ]; then
set -x
fi
function request(){
METHOD=$1
URL=$2
DATA=$3
if [ "$DATA" != "" ]; then
DATA="--data $DATA"
fi
OUTPUT_FILE=/tmp/circleci-response-$RANDOM.json
STATUS_CODE=$(curl -o $OUTPUT_FILE -sL -w "%{http_code}" -X $METHOD $URL \
--header "content-type: application/json" --header "accept: application/json" \
--header "x-attribution-login: ${{ github.actor }}" --header "x-attribution-actor-id: ${{ github.actor }}" \
--header "Circle-Token: ${{ secrets.CIRCLECI_TOKEN }}" $DATA )
cat $OUTPUT_FILE
rm $OUTPUT_FILE
}
request POST https://circleci.com/api/v2/workflow/${{ steps.circle-ci-trigger.outputs.workflow_id }}/cancel
2 changes: 1 addition & 1 deletion .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
if: github.event.action == 'synchronize' && false # disable until https://github.com/kumahq/kuma/issues/9482
env:
GITHUB_TOKEN: ${{ github.token }}
PREDEFINED_GLOBS: ".github/**/*,.circleci/**/*,Makefile,mk/**/*,tools/**/*,.golangci.yml,.kube-linter.yaml"
PREDEFINED_GLOBS: ".github/**/*,Makefile,mk/**/*,tools/**/*,.golangci.yml,.kube-linter.yaml"
LABEL_TO_ADD: backport
NO_BACKPORT_AUTOLABEL: no-backport-autolabel
run: |
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

**Builds**

[![CircleCI master](https://img.shields.io/circleci/build/github/kumahq/kuma/master?label=master)](https://circleci.com/gh/kumahq/kuma/tree/master)
![GitHub Actions master](https://github.com/kumahq/kuma/actions/workflows/build-test-distribute.yaml/badge.svg?branch=master)

**Code quality**

Expand Down
1 change: 0 additions & 1 deletion mk/check.mk
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ golangci-lint-fmt:

.PHONY: fmt/ci
fmt/ci:
$(YQ) -i '.parameters.go_version.default = "$(GO_VERSION)" | .parameters.first_k8s_version.default = "$(K8S_MIN_VERSION)" | .parameters.last_k8s_version.default = "$(K8S_MAX_VERSION)"' .circleci/config.yml
$(YQ) -i '.env.K8S_MIN_VERSION = "$(K8S_MIN_VERSION)" | .env.K8S_MAX_VERSION = "$(K8S_MAX_VERSION)"' .github/workflows/"$(ACTION_PREFIX)"_test.yaml
grep -r "golangci/golangci-lint-action" .github/workflows --include \*ml | cut -d ':' -f 1 | xargs -n 1 $(YQ) -i '(.jobs.* | select(. | has("steps")) | .steps[] | select(.uses == "golangci/golangci-lint-action*") | .with.version) |= "$(GOLANGCI_LINT_VERSION)"'

Expand Down
4 changes: 2 additions & 2 deletions test/e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ Executing those tests is very expensive, it is the longest job on the CI.
Adding the tests here potentially slows down the velocity of all contributors.
Please consider writing the test in `e2e_env` directory instead, where all the tests are parallelized on one Kuma deployment.

On CircleCI, all the tests are parallelized into multiple VMs. You can control on which VM the test will run using `job-X` label.
All the tests requires `job-X` label, otherwise CircleCI won't run them.
All the tests are parallelized into multiple VMs. You can control on which VM the test will run using `job-X` label.
All the tests require `job-X` label, otherwise they won't be run.

## Reasons to write the test in this package over `e2e_env`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ for dep in $(osv-scanner "$OSV_SCANNER_ADDITIONAL_OPTS" --lockfile=go.mod --json
echo "Updating $package to $fixVersion"

if [[ "$package" == "stdlib" ]]; then
yq -i e ".parameters.go_version.default = \"$fixVersion\"" .circleci/config.yml
go mod edit -go="$fixVersion"
else
go get -u "$package"@v"$fixVersion"
Expand Down

0 comments on commit c822771

Please sign in to comment.