forked from argoproj/argo-cd
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Migrate CI toolchain to GitHub actions (argoproj#3677)
* chore: Migrate CI to GitHub actions * Do not install golangci-lint, we use the action * Integrate codecov.io upload * Use some better names for analyze job & steps * go mod tidy * Update tools * Disable CircleCI completely * Satisfy CircleCI with a dummy step until it's disabled
- Loading branch information
Showing
27 changed files
with
793 additions
and
400 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,323 +1,16 @@ | ||
version: 2.1 | ||
commands: | ||
prepare_environment: | ||
steps: | ||
- run: | ||
name: Configure environment | ||
command: | | ||
set -x | ||
echo "export GOCACHE=/tmp/go-build-cache" | tee -a $BASH_ENV | ||
echo "export ARGOCD_TEST_VERBOSE=true" | tee -a $BASH_ENV | ||
echo "export ARGOCD_TEST_PARALLELISM=4" | tee -a $BASH_ENV | ||
echo "export ARGOCD_SONAR_VERSION=4.2.0.1873" | tee -a $BASH_ENV | ||
configure_git: | ||
steps: | ||
- run: | ||
name: Configure Git | ||
command: | | ||
set -x | ||
# must be configured for tests to run | ||
git config --global user.email [email protected] | ||
git config --global user.name "Your Name" | ||
echo "export PATH=/home/circleci/.go_workspace/src/github.com/argoproj/argo-cd/hack:\$PATH" | tee -a $BASH_ENV | ||
echo "export GIT_ASKPASS=git-ask-pass.sh" | tee -a $BASH_ENV | ||
setup_go_modules: | ||
steps: | ||
- run: | ||
name: Run go mod download and populate vendor | ||
command: | | ||
go mod download | ||
go mod vendor | ||
save_coverage_info: | ||
steps: | ||
- persist_to_workspace: | ||
root: . | ||
paths: | ||
- coverage.out | ||
save_node_modules: | ||
steps: | ||
- persist_to_workspace: | ||
root: ~/argo-cd | ||
paths: | ||
- ui/node_modules | ||
save_go_cache: | ||
steps: | ||
- persist_to_workspace: | ||
root: /tmp | ||
paths: | ||
- go-build-cache | ||
attach_go_cache: | ||
steps: | ||
- attach_workspace: | ||
at: /tmp | ||
install_golang: | ||
steps: | ||
- run: | ||
name: Install Golang v1.14.1 | ||
command: | | ||
go get golang.org/dl/go1.14.1 | ||
[ -e /home/circleci/sdk/go1.14.1 ] || go1.14.1 download | ||
go env | ||
echo "export GOPATH=/home/circleci/.go_workspace" | tee -a $BASH_ENV | ||
echo "export PATH=/home/circleci/sdk/go1.14.1/bin:\$PATH" | tee -a $BASH_ENV | ||
jobs: | ||
build: | ||
docker: | ||
- image: argoproj/argocd-test-tools:v0.5.0 | ||
working_directory: /go/src/github.com/argoproj/argo-cd | ||
steps: | ||
- prepare_environment | ||
- checkout | ||
- run: make build-local | ||
- run: chmod -R 777 vendor | ||
- run: chmod -R 777 ${GOCACHE} | ||
- save_go_cache | ||
|
||
codegen: | ||
docker: | ||
- image: argoproj/argocd-test-tools:v0.5.0 | ||
working_directory: /go/src/github.com/argoproj/argo-cd | ||
steps: | ||
- prepare_environment | ||
- checkout | ||
- attach_go_cache | ||
- run: helm2 init --client-only | ||
- run: make codegen-local | ||
- run: | ||
name: Check nothing has changed | ||
command: | | ||
set -xo pipefail | ||
# This makes sure you ran `make pre-commit` before you pushed. | ||
# We exclude the Swagger resources; CircleCI doesn't generate them correctly. | ||
# When this fails, it will, create a patch file you can apply locally to fix it. | ||
# To troubleshoot builds: https://argoproj.github.io/argo-cd/developer-guide/ci/ | ||
git diff --exit-code -- . ':!Gopkg.lock' ':!assets/swagger.json' | tee codegen.patch | ||
- store_artifacts: | ||
path: codegen.patch | ||
destination: . | ||
test: | ||
working_directory: /go/src/github.com/argoproj/argo-cd | ||
dummy: | ||
docker: | ||
- image: argoproj/argocd-test-tools:v0.5.0 | ||
- image: cimg/base:2020.01 | ||
steps: | ||
- prepare_environment | ||
- checkout | ||
- configure_git | ||
- attach_go_cache | ||
- run: make test-local | ||
- run: | ||
name: Uploading code coverage | ||
command: bash <(curl -s https://codecov.io/bash) -f coverage.out | ||
- run: | ||
name: Output of test-results | ||
name: Dummy step | ||
command: | | ||
ls -l test-results || true | ||
cat test-results/junit.xml || true | ||
- save_coverage_info | ||
- store_test_results: | ||
path: test-results | ||
- store_artifacts: | ||
path: test-results | ||
destination: . | ||
|
||
lint: | ||
working_directory: /go/src/github.com/argoproj/argo-cd | ||
docker: | ||
- image: argoproj/argocd-test-tools:v0.5.0 | ||
steps: | ||
- prepare_environment | ||
- checkout | ||
- configure_git | ||
- attach_vendor | ||
- store_go_cache_docker | ||
- run: | ||
name: Run golangci-lint | ||
command: ARGOCD_LINT_GOGC=10 make lint-local | ||
- run: | ||
name: Check that nothing has changed | ||
command: | | ||
gDiff=$(git diff) | ||
if test "$gDiff" != ""; then | ||
echo | ||
echo "###############################################################################" | ||
echo "golangci-lint has made automatic corrections to your code. Please check below" | ||
echo "diff output and commit this to your local branch, or run make lint locally." | ||
echo "###############################################################################" | ||
echo | ||
git diff | ||
exit 1 | ||
fi | ||
sonarcloud: | ||
working_directory: /go/src/github.com/argoproj/argo-cd | ||
docker: | ||
- image: argoproj/argocd-test-tools:v0.5.0 | ||
environment: | ||
NODE_MODULES: /go/src/github.com/argoproj/argo-cd/ui/node_modules | ||
steps: | ||
- prepare_environment | ||
- checkout | ||
- attach_workspace: | ||
at: . | ||
- run: | ||
command: mkdir -p /tmp/cache/scanner | ||
name: Create cache directory if it doesn't exist | ||
- restore_cache: | ||
keys: | ||
- v1-sonarcloud-scanner-4.2.0.1873 | ||
- run: | ||
command: | | ||
set -e | ||
VERSION=4.2.0.1873 | ||
SONAR_TOKEN=$SONAR_TOKEN | ||
SCANNER_DIRECTORY=/tmp/cache/scanner | ||
export SONAR_USER_HOME=$SCANNER_DIRECTORY/.sonar | ||
OS="linux" | ||
echo $SONAR_USER_HOME | ||
if [[ ! -x "$SCANNER_DIRECTORY/sonar-scanner-$VERSION-$OS/bin/sonar-scanner" ]]; then | ||
curl -Ol https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$VERSION-$OS.zip | ||
unzip -qq -o sonar-scanner-cli-$VERSION-$OS.zip -d $SCANNER_DIRECTORY | ||
fi | ||
chmod +x $SCANNER_DIRECTORY/sonar-scanner-$VERSION-$OS/bin/sonar-scanner | ||
chmod +x $SCANNER_DIRECTORY/sonar-scanner-$VERSION-$OS/jre/bin/java | ||
# Workaround for a possible bug in CircleCI | ||
if ! echo $CIRCLE_PULL_REQUEST | grep https://github.com/argoproj; then | ||
unset CIRCLE_PULL_REQUEST | ||
unset CIRCLE_PULL_REQUESTS | ||
fi | ||
# Explicitly set NODE_MODULES | ||
export NODE_MODULES=/go/src/github.com/argoproj/argo-cd/ui/node_modules | ||
export NODE_PATH=/go/src/github.com/argoproj/argo-cd/ui/node_modules | ||
$SCANNER_DIRECTORY/sonar-scanner-$VERSION-$OS/bin/sonar-scanner | ||
name: SonarCloud | ||
- save_cache: | ||
key: v1-sonarcloud-scanner-4.2.0.1873 | ||
paths: | ||
- /tmp/cache/scanner | ||
|
||
e2e: | ||
working_directory: /home/circleci/.go_workspace/src/github.com/argoproj/argo-cd | ||
machine: | ||
image: ubuntu-1604:201903-01 | ||
environment: | ||
ARGOCD_FAKE_IN_CLUSTER: "true" | ||
ARGOCD_SSH_DATA_PATH: "/tmp/argo-e2e/app/config/ssh" | ||
ARGOCD_TLS_DATA_PATH: "/tmp/argo-e2e/app/config/tls" | ||
ARGOCD_E2E_K3S: "true" | ||
steps: | ||
- run: | ||
name: Install and start K3S v0.5.0 | ||
command: | | ||
curl -sfL https://get.k3s.io | sh - | ||
sudo chmod -R a+rw /etc/rancher/k3s | ||
kubectl version | ||
environment: | ||
INSTALL_K3S_EXEC: --docker | ||
INSTALL_K3S_VERSION: v0.5.0 | ||
- prepare_environment | ||
- checkout | ||
- run: | ||
name: Fix permissions on filesystem | ||
command: | | ||
mkdir -p /home/circleci/.go_workspace/pkg/mod | ||
chmod -R 777 /home/circleci/.go_workspace/pkg/mod | ||
mkdir -p /tmp/go-build-cache | ||
chmod -R 777 /tmp/go-build-cache | ||
- attach_go_cache | ||
- run: | ||
name: Update kubectl configuration for container | ||
command: | | ||
ipaddr=$(ifconfig $IFACE |grep "inet " | awk '{print $2}') | ||
if echo $ipaddr | grep -q 'addr:'; then | ||
ipaddr=$(echo $ipaddr | awk -F ':' '{print $2}') | ||
fi | ||
test -d $HOME/.kube || mkdir -p $HOME/.kube | ||
kubectl config view --raw | sed -e "s/127.0.0.1:6443/${ipaddr}:6443/g" -e "s/localhost:6443/${ipaddr}:6443/g" > $HOME/.kube/config | ||
environment: | ||
IFACE: ens4 | ||
- run: | ||
name: Start E2E test server | ||
command: make start-e2e | ||
background: true | ||
environment: | ||
DOCKER_SRCDIR: /home/circleci/.go_workspace/src | ||
ARGOCD_E2E_TEST: "true" | ||
ARGOCD_IN_CI: "true" | ||
GOPATH: /home/circleci/.go_workspace | ||
- run: | ||
name: Wait for API server to become available | ||
command: | | ||
count=1 | ||
until curl -v http://localhost:8080/healthz; do | ||
sleep 10; | ||
if test $count -ge 60; then | ||
echo "Timeout" | ||
exit 1 | ||
fi | ||
count=$((count+1)) | ||
done | ||
- run: | ||
name: Run E2E tests | ||
command: | | ||
make test-e2e | ||
environment: | ||
ARGOCD_OPTS: "--plaintext" | ||
ARGOCD_E2E_K3S: "true" | ||
IFACE: ens4 | ||
DOCKER_SRCDIR: /home/circleci/.go_workspace/src | ||
GOPATH: /home/circleci/.go_workspace | ||
- store_test_results: | ||
path: test-results | ||
- store_artifacts: | ||
path: test-results | ||
destination: . | ||
ui: | ||
docker: | ||
- image: node:11.15.0 | ||
working_directory: ~/argo-cd/ui | ||
steps: | ||
- checkout: | ||
path: ~/argo-cd/ | ||
- restore_cache: | ||
keys: | ||
- yarn-packages-v4-{{ checksum "yarn.lock" }} | ||
- run: yarn install --frozen-lockfile --ignore-optional --non-interactive | ||
- save_cache: | ||
key: yarn-packages-v4-{{ checksum "yarn.lock" }} | ||
paths: [~/.cache/yarn, node_modules] | ||
- run: yarn test | ||
- run: ./node_modules/.bin/codecov -p .. | ||
- run: NODE_ENV='production' yarn build | ||
- run: yarn lint | ||
- save_node_modules | ||
|
||
orbs: | ||
sonarcloud: sonarsource/[email protected] | ||
echo "This is a dummy step to satisfy CircleCI" | ||
workflows: | ||
version: 2 | ||
workflow: | ||
jobs: | ||
- build | ||
- test: | ||
requires: | ||
- build | ||
- codegen: | ||
requires: | ||
- build | ||
- ui: | ||
requires: | ||
- build | ||
- sonarcloud: | ||
context: SonarCloud | ||
requires: | ||
- test | ||
- ui | ||
- e2e: | ||
requires: | ||
- build | ||
jobs: | ||
- dummy |
Oops, something went wrong.