Skip to content

Commit

Permalink
build: refactor circleci so sonar shows latest test results again AND…
Browse files Browse the repository at this point in the history
… remove formatcheck precommit hook (#3224)

* build: refactor so sonar shows latest test results again

* small changes

* small fixes

* make gradle cache build javascript so it doesn't build again on test

* make javascript build caching properly so step is skipped if files not touchedf

* remove formatcheck, we only should do apply

* move checkformat to build step

* fix that javascript build should go before resources are processed into jar

* merge prepare and build to save some overhead

* merge prepare and build to save some overhead

* merge prepare and build to save some overhead

* remove unused docker in build phase

* fix

* move format to the build instead of test otherwise build repeats

* simplify
  • Loading branch information
mswertz authored Jan 18, 2024
1 parent 877aced commit 3254fb0
Showing 1 changed file with 24 additions and 55 deletions.
79 changes: 24 additions & 55 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@ version: 2
orbs:
slack: circleci/[email protected]
jobs:
prepare:
build:
docker:
# specify the version you desire here
- image: molgenis/ci-build:latest
working_directory: ~/repo
resource_class: large

environment:
JVM_OPTS: -Xmx3200m
GRADLE_OPTS: "-Dorg.gradle.daemon=false -Dorg.gradle.workers.max=2"
TERM: dumb

steps:
- checkout
Expand All @@ -33,50 +39,20 @@ jobs:
- ~/.gradle
key: v1-dependencies-{{ checksum "build.gradle" }}

- setup_remote_docker:
version: 19.03.13
docker_layer_caching: true

- run:
name: Sign in to docker
command: docker login -u $DOCKER_USER -p $DOCKER_PASS

- run:
name: Setup git, todo, move to molgenisci user
command: |
git config --global --add safe.directory '*'
git config user.email "[email protected]"
git config user.name "mswertz"
git config url.https://.insteadOf git://
- persist_to_workspace:
root: .
paths:
- .

build:
docker:
- image: molgenis/ci-build:latest
- image: postgres:15-alpine
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
working_directory: ~/repo

# The resource_class feature allows configuring CPU and RAM resources for each job. Different resource classes are available for different executors. https://circleci.com/docs/2.0/configuration-reference/#resourceclass
resource_class: large

environment:
JVM_OPTS: -Xmx3200m
GRADLE_OPTS: "-Dorg.gradle.daemon=false -Dorg.gradle.workers.max=2"
TERM: dumb
steps:
- attach_workspace:
at: ~/repo
- run:
name: build jar and compile test classes and export 'ci' config
command: |
./gradlew clean testClasses shadowJar ci
export $( cat build/ci.properties | xargs )
- run: ./gradlew clean assemble testClasses ci

- persist_to_workspace:
root: .
paths:
Expand Down Expand Up @@ -106,14 +82,10 @@ jobs:
command: docker login -u $DOCKER_USER -p $DOCKER_PASS

- run:
name: push emx2 docker images
name: push emx2 docker images and helm for the preview
command: |
echo "PR number: ${CIRCLE_PULL_REQUEST##*/}"
./gradlew -s jacocoMergedReport --no-daemon shadowJar dockerPush helmPublishMainChart ci sonar -x test -x :apps:buildJavascript -x :apps:checkFormat -x :apps:testJavaScript \
-Dorg.ajoberstar.grgit.auth.username=${GITHUB_TOKEN} -Dorg.ajoberstar.grgit.auth.password \
-Dsonar.login=${SONAR_TOKEN} -Dsonar.organization=molgenis -Dsonar.host.url=https://sonarcloud.io -Dsonar.verbose=true \
-Dsonar.pullrequest.key=${CIRCLE_PULL_REQUEST##*/} -Dsonar.pullrequest.branch=${CIRCLE_BRANCH}
export $( cat build/ci.properties | xargs )
./gradlew -s --no-daemon dockerPush helmPublishMainChart
- run:
name: push ssr-catalogue docker images
Expand Down Expand Up @@ -173,7 +145,13 @@ jobs:

- run: psql -h 127.0.0.1 -p 5432 -U postgres < .docker/initdb.sql

- run: ./gradlew test --no-daemon
- run:
name: Run tests, merge test results using jacoco and push test results to sonar
command: |
./gradlew test jacocoMergedReport sonar -x apps:format -x apps:buildJavaScript --no-daemon \
-Dorg.ajoberstar.grgit.auth.username=${GITHUB_TOKEN} -Dorg.ajoberstar.grgit.auth.password \
-Dsonar.login=${SONAR_TOKEN} -Dsonar.organization=molgenis -Dsonar.host.url=https://sonarcloud.io -Dsonar.verbose=true \
-Dsonar.pullrequest.key=${CIRCLE_PULL_REQUEST##*/} -Dsonar.pullrequest.branch=${CIRCLE_BRANCH}
- run:
name: Save test results
Expand Down Expand Up @@ -208,23 +186,17 @@ jobs:
command: docker login -u $DOCKER_USER -p $DOCKER_PASS

- run:
name: release, push docker, push python
name: release, push release docker, push release python
command: |
export $( cat build/ci.properties | xargs )
./gradlew -s jacocoMergedReport --no-daemon shadowJar dockerPush helmPublishMainChart release -x test -x :apps:buildJavascript -x :apps:checkFormat -x :apps:testJavaScript \
-Dorg.ajoberstar.grgit.auth.username=${GITHUB_TOKEN} -Dorg.ajoberstar.grgit.auth.password \
-Dsonar.login=${SONAR_TOKEN} -Dsonar.organization=molgenis -Dsonar.host.url=https://sonarcloud.io -Dsonar.verbose=true
./gradlew -s --no-daemon dockerPush helmPublishMainChart release
if [[ "$TAG_NAME" == *"SNAPSHOT"* ]]; then
docker build apps/nuxt3-ssr/ -t molgenis/ssr-catalogue-snapshot:latest -t molgenis/ssr-catalogue-snapshot:${TAG_NAME}
docker push molgenis/ssr-catalogue-snapshot --all-tags
else
docker build apps/nuxt3-ssr/ -t molgenis/ssr-catalogue:latest -t molgenis/ssr-catalogue:${TAG_NAME}
docker push molgenis/ssr-catalogue --all-tags
fi
environment:
MOLGENIS_POSTGRES_USER: molgenis
MOLGENIS_POSTGRES_PASS: molgenis
MOLGENIS_POSTGRES_URI: jdbc:postgresql://localhost/molgenis
- run:
name: update rug server
Expand Down Expand Up @@ -254,10 +226,7 @@ workflows:
version: 2
build_and_test_and_preview_or_release:
jobs:
- prepare
- build:
requires:
- prepare
- build
- preview:
requires:
- build
Expand Down

0 comments on commit 3254fb0

Please sign in to comment.