Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add automatic dev deployment on push #7657

Draft
wants to merge 14 commits into
base: master
Choose a base branch
from
111 changes: 28 additions & 83 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ jobs:
key: webpack-cache-{{ checksum ".circleci/cache_version" }}-{{ .Branch }}-{{ .Revision }}
paths:
- "node_modules/.cache/webpack"

- run:
name: Build webknossos docker image
command: docker-compose build --pull webknossos
Expand All @@ -124,86 +123,6 @@ jobs:
- run:
name: Build webknossos-tracingstore docker image
command: docker-compose build --pull webknossos-tracingstore

- run:
name: Lint frontend code (rome and eslint) and check formatting
command: |
.circleci/not-on-master.sh docker-compose run base bash -c "yarn run lint && yarn run am-i-pretty"
- run:
name: Check for cyclic dependencies in front-end
command: |
.circleci/not-on-master.sh docker-compose run base yarn check-cyclic-dependencies
- run:
name: Run frontend tests
command: |
.circleci/not-on-master.sh docker-compose run base yarn test-verbose
- run:
name: Lint backend code and check formatting
command: |
.circleci/not-on-master.sh docker-compose run backend-lint-format
- run:
name: Run backend tests
command: |
.circleci/not-on-master.sh docker-compose run backend-tests
- run:
name: Run end-to-end tests
command: |
for i in {1..3}; do # retry
.circleci/not-on-master.sh docker-compose run e2e-tests && s=0 && break || s=$?
done
(exit $s)
- run:
name: Validate frontend types
command: |
.circleci/not-on-master.sh docker-compose run base yarn typecheck
- run:
name: Start webknossos
background: true
command: docker-compose up webknossos
- run:
name: Run webknossos smoke test
command: |
for i in {1..10}; do # retry
sleep 10
curl --fail -v http://localhost:9000/api/health && s=0 && break || s=$?
done
(exit $s)
- run:
name: Stop webknossos
command: docker-compose down --volumes --remove-orphans

- run:
name: Start webknossos-datastore
background: true
command: docker-compose up webknossos-datastore
- run:
name: Run webknossos-datastore smoke test
command: |
for i in {1..10}; do # retry
sleep 10
curl --fail -v http://localhost:9090/data/health && s=0 && break || s=$?
done
(exit $s)
- run:
name: Stop webknossos-datastore
command: docker-compose down --volumes --remove-orphans

- run:
name: Start webknossos-tracingstore
background: true
command: docker-compose up webknossos-tracingstore
- run:
name: Run webknossos-tracingstore smoke test
command: |
for i in {1..10}; do # retry
sleep 10
curl --fail -v http://localhost:9050/tracings/health && s=0 && break || s=$?
done
(exit $s)
- run:
name: Stop webknossos-tracingstore
command: docker-compose down --volumes --remove-orphans

- run:
name: Push docker images
command: |
Expand Down Expand Up @@ -238,8 +157,34 @@ jobs:
fi
docker logout
- run:
name: Report coverage
command: .circleci/not-on-master.sh docker-compose run base yarn coverage || true
name: Install dev deployment
command: |
if [ "${CIRCLE_BRANCH}" != "master" ]; then
PR_URL="$CIRCLE_PULL_REQUEST"
PR_NUMBER=$(echo $PR_URL | awk -F'/' '{print $NF}')
SHOULD_AUTODEPLOY=$(curl "https://api.github.com/repos/scalableminds/webknossos/pulls/${PR_NUMBER}" | jq -e '.labels | .[] | select(.name == "autodeploy")')
if [ "$?" -eq "0" ]
then
echo "Starting autodeploy"
curl -X POST -H "X-Auth-Token: $RELEASE_API_TOKEN" "https://kubernetix.scm.io/hooks/install/webknossos/dev/${CIRCLE_BRANCH}?user=CI+%28nightly%29"
echo "\nInstalled to $NORMALIZED_BRANCH.webknossos.xyz"

# Install gh client
sudo mkdir -p -m 755 /etc/apt/keyrings && wget -qO- https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \
&& sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
&& sudo apt update \
&& sudo apt install gh -y
gh auth status

CURRENT_BODY=$(gh pr view $PR_NUMBER --json body | jq -r '.body')
echo "CURRENT_BODY=$CURRENT_BODY"
UPDATED_BODY=$(echo $CURRENT_BODY | sed "s|https://___.webknossos.xyz|https://$NORMALIZED_BRANCH.webknossos.xyz|g")
echo "UPDATED_BODY=$UPDATED_BODY"

echo $UPDATED_BODY | gh pr edit $PR_NUMBER -F -
fi
fi
- run:
name: Send Slack notification (master only)
command: .circleci/slack-notification.sh
Expand Down