diff --git a/.detekt.yml b/.detekt.yml new file mode 100644 index 00000000..464f0c05 --- /dev/null +++ b/.detekt.yml @@ -0,0 +1,23 @@ +complexity: + TooManyFunctions: + active: false + +style: + ThrowsCount: + active: false + MaxLineLength: + active: false + ReturnCount: + active: false + +performance: + SpreadOperator: + active: false + +comments: + UndocumentedPublicClass: + active: true + UndocumentedPublicFunction: + active: true + UndocumentedPublicProperty: + active: true diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ebf093d3..d91b29e5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,10 +4,11 @@ on: push: branches: - master - - version-* + - release-* env: GRADLE_OPTS: -Dorg.gradle.daemon=false -Xmx2g -Xms2g + CONTAINER_REGISTRY: us-docker.pkg.dev/spinnaker-community/docker jobs: branch-build: @@ -16,10 +17,98 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 - uses: actions/setup-java@v4 with: - java-version: 11 + java-version: | + 17 + 11 distribution: 'zulu' cache: 'gradle' + - name: Prepare build variables + id: build_variables + run: | + echo REPO="${GITHUB_REPOSITORY##*/}" >> $GITHUB_OUTPUT + echo VERSION="$(git describe --tags --abbrev=0 --match='v[0-9]*' | cut -c2-)-dev-${GITHUB_REF_NAME}-$(git rev-parse --short HEAD)-$(date --utc +'%Y%m%d%H%M')" >> $GITHUB_OUTPUT - name: Build - run: ./gradlew build --stacktrace + env: + ORG_GRADLE_PROJECT_version: ${{ steps.build_variables.outputs.VERSION }} + run: ./gradlew build --stacktrace ${{ steps.build_variables.outputs.REPO }}-web:installDist + - name: Build local slim container image for testing + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.slim + load: true + platforms: local + tags: | + "${{ steps.build_variables.outputs.REPO }}:${{ steps.build_variables.outputs.VERSION }}-unvalidated" + - name: Test local slim container image + env: + FULL_DOCKER_IMAGE_NAME: "${{ steps.build_variables.outputs.REPO }}:${{ steps.build_variables.outputs.VERSION }}-unvalidated" + run: ./gradlew ${{ steps.build_variables.outputs.REPO }}-integration:test + - name: Login to GAR + # Only run this on repositories in the 'spinnaker' org, not on forks. + if: startsWith(github.repository, 'spinnaker/') + uses: docker/login-action@v3 + # use service account flow defined at: https://github.com/docker/login-action#service-account-based-authentication-1 + with: + registry: us-docker.pkg.dev + username: _json_key + password: ${{ secrets.GAR_JSON_KEY }} + - name: Build and publish slim container image + # Only run this on repositories in the 'spinnaker' org, not on forks. + if: startsWith(github.repository, 'spinnaker/') + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.slim + platforms: linux/amd64,linux/arm64 + push: true + tags: | + "${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ github.ref_name }}-latest-unvalidated" + "${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.build_variables.outputs.VERSION }}-unvalidated" + "${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ github.ref_name }}-latest-unvalidated-slim" + "${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.build_variables.outputs.VERSION }}-unvalidated-slim" + - name: Build and publish ubuntu container image + # Only run this on repositories in the 'spinnaker' org, not on forks. + if: startsWith(github.repository, 'spinnaker/') + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.ubuntu + platforms: linux/amd64,linux/arm64 + push: true + tags: | + "${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ github.ref_name }}-latest-unvalidated-ubuntu" + "${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.build_variables.outputs.VERSION }}-unvalidated-ubuntu" + - name: Build and publish slim JRE 11 container image + # Only run this on repositories in the 'spinnaker' org, not on forks. + if: startsWith(github.repository, 'spinnaker/') + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.java11.slim + platforms: linux/amd64,linux/arm64 + push: true + tags: | + "${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ github.ref_name }}-latest-java11-unvalidated" + "${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.build_variables.outputs.VERSION }}-java11-unvalidated" + "${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ github.ref_name }}-latest-java11-unvalidated-slim" + "${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.build_variables.outputs.VERSION }}-java11-unvalidated-slim" + - name: Build and publish ubuntu JRE 11 container image + # Only run this on repositories in the 'spinnaker' org, not on forks. + if: startsWith(github.repository, 'spinnaker/') + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.java11.ubuntu + push: true + tags: | + "${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ github.ref_name }}-latest-java11-unvalidated-ubuntu" + "${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.build_variables.outputs.VERSION }}-java11-unvalidated-ubuntu" diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 3d4281aa..4cbd9897 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -4,16 +4,82 @@ on: [ pull_request ] env: GRADLE_OPTS: -Dorg.gradle.daemon=false -Xmx2g -Xms2g + CONTAINER_REGISTRY: us-docker.pkg.dev/spinnaker-community/docker jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: actions/setup-java@v4 - with: - java-version: 11 - distribution: 'zulu' - cache: 'gradle' - - name: Build - run: ./gradlew build + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - uses: actions/setup-java@v4 + with: + java-version: | + 17 + 11 + distribution: 'zulu' + cache: 'gradle' + - name: Prepare build variables + id: build_variables + run: | + echo REPO="${GITHUB_REPOSITORY##*/}" >> $GITHUB_OUTPUT + echo VERSION="$(git describe --tags --abbrev=0 --match='v[0-9]*' | cut -c2-)-dev-pr-$(git rev-parse --short HEAD)-$(date --utc +'%Y%m%d%H%M')" >> $GITHUB_OUTPUT + - name: Build + env: + ORG_GRADLE_PROJECT_version: ${{ steps.build_variables.outputs.VERSION }} + run: ./gradlew build ${{ steps.build_variables.outputs.REPO }}-web:installDist + - name: Build slim container image + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.slim + platforms: linux/amd64,linux/arm64 + tags: | + "${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:latest" + "${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.build_variables.outputs.VERSION }}" + "${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:latest-slim" + "${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.build_variables.outputs.VERSION }}-slim" + - name: Build ubuntu container image + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.ubuntu + platforms: linux/amd64,linux/arm64 + tags: | + "${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:latest-ubuntu" + "${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.build_variables.outputs.VERSION }}-ubuntu" + - name: Build slim JRE 11 container image + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.java11.slim + platforms: linux/amd64,linux/arm64 + tags: | + "${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:latest-java11" + "${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.build_variables.outputs.VERSION }}-java11" + "${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:latest-java11-slim" + "${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.build_variables.outputs.VERSION }}-java11-slim" + - name: Build ubuntu JRE 11 container image + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.java11.ubuntu + platforms: linux/amd64,linux/arm64 + tags: | + "${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:latest-java11-ubuntu" + "${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.build_variables.outputs.VERSION }}-java11-ubuntu" + - name: Build local slim container image for testing + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.slim + load: true + platforms: local + tags: | + "${{ steps.build_variables.outputs.REPO }}:${{ steps.build_variables.outputs.VERSION }}" + diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1ae43c0b..6f233c3e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,16 +8,44 @@ on: env: GRADLE_OPTS: -Dorg.gradle.daemon=false -Xmx2g -Xms2g + CONTAINER_REGISTRY: us-docker.pkg.dev/spinnaker-community/docker jobs: release: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - run: git fetch --prune --unshallow + with: + fetch-depth: 0 + # Given a tag, determine what branch we are on, so we can bump dependencies in the correct branch + - name: Get Branch + run: | + BRANCHES=$(git branch -r --contains ${{ github.ref }}) + echo "BRANCHES is '${BRANCHES}'" + # Check for no branches explicitly...Otherwise echo adds a newline so wc thinks there's + # one branch. And echo -n makes it appears that there's one less branch than there + # actually is. + if [ -z "$BRANCHES" ]; then + echo "exactly one branch required to release swabbie, but there are none" + exit 1 + fi + NUM_BRANCHES=$(($(echo "$BRANCHES" | wc -l))) + echo "NUM_BRANCHES is '${NUM_BRANCHES}'" + if [ $NUM_BRANCHES -ne 1 ]; then + echo "exactly one branch required to release swabbie, but there are $NUM_BRANCHES ($BRANCHES)" + exit 1 + fi + echo "exactly one branch ($BRANCHES)" + echo BRANCH=$BRANCHES >> $GITHUB_ENV + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 - uses: actions/setup-java@v4 with: - java-version: 11 + java-version: | + 17 + 11 distribution: 'zulu' cache: 'gradle' - name: Assemble release info @@ -30,16 +58,97 @@ jobs: echo SKIP_RELEASE="${SKIP_RELEASE}" >> $GITHUB_OUTPUT echo IS_CANDIDATE="${IS_CANDIDATE}" >> $GITHUB_OUTPUT echo RELEASE_VERSION="${RELEASE_VERSION}" >> $GITHUB_OUTPUT + - name: Prepare build variables + id: build_variables + run: | + echo REPO="${GITHUB_REPOSITORY##*/}" >> $GITHUB_OUTPUT + echo VERSION="$(git rev-parse --short HEAD)-$(date --utc +'%Y%m%d%H%M')" >> $GITHUB_OUTPUT - name: Release build env: - BINTRAY_USER: ${{ secrets.BINTRAY_USER }} - BINTRAY_API_KEY: ${{ secrets.BINTRAY_API_KEY }} - RELEASE_VERSION: ${{ steps.release_info.outputs.RELEASE_VERSION }} + ORG_GRADLE_PROJECT_version: ${{ steps.release_info.outputs.RELEASE_VERSION }} + ORG_GRADLE_PROJECT_nexusPublishEnabled: true + ORG_GRADLE_PROJECT_nexusUsername: ${{ secrets.NEXUS_USERNAME }} + ORG_GRADLE_PROJECT_nexusPassword: ${{ secrets.NEXUS_PASSWORD }} + ORG_GRADLE_PROJECT_nexusPgpSigningKey: ${{ secrets.NEXUS_PGP_SIGNING_KEY }} + ORG_GRADLE_PROJECT_nexusPgpSigningPassword: ${{ secrets.NEXUS_PGP_SIGNING_PASSWORD }} run: | - ./gradlew --info -Pversion="${RELEASE_VERSION}" -PbintrayUser="${BINTRAY_USER}" -PbintrayKey="${BINTRAY_API_KEY}" -PbintrayPublishDebEnabled=false publish + ./gradlew --info build ${{ steps.build_variables.outputs.REPO }}-web:installDist publishToNexus closeAndReleaseNexusStagingRepository + - name: Publish apt packages to Google Artifact Registry + env: + ORG_GRADLE_PROJECT_version: ${{ steps.release_info.outputs.RELEASE_VERSION }} + ORG_GRADLE_PROJECT_artifactRegistryPublishEnabled: true + GAR_JSON_KEY: ${{ secrets.GAR_JSON_KEY }} + run: | + ./gradlew --info publish + - name: Login to Google Cloud + # Only run this on repositories in the 'spinnaker' org, not on forks. + if: startsWith(github.repository, 'spinnaker/') + uses: 'google-github-actions/auth@v2' + # use service account flow defined at: https://github.com/google-github-actions/upload-cloud-storage#authenticating-via-service-account-key-json + with: + credentials_json: '${{ secrets.GAR_JSON_KEY }}' + - name: Login to GAR + # Only run this on repositories in the 'spinnaker' org, not on forks. + if: startsWith(github.repository, 'spinnaker/') + uses: docker/login-action@v3 + # use service account flow defined at: https://github.com/docker/login-action#service-account-based-authentication-1 + with: + registry: us-docker.pkg.dev + username: _json_key + password: ${{ secrets.GAR_JSON_KEY }} + - name: Build and publish slim container image + # Only run this on repositories in the 'spinnaker' org, not on forks. + if: startsWith(github.repository, 'spinnaker/') + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.slim + platforms: linux/amd64,linux/arm64 + push: true + tags: | + "${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.release_info.outputs.RELEASE_VERSION }}-unvalidated" + "${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.release_info.outputs.RELEASE_VERSION }}-unvalidated-slim" + "${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.release_info.outputs.RELEASE_VERSION }}-${{ steps.build_variables.outputs.VERSION }}-unvalidated-slim" + - name: Build and publish ubuntu container image + # Only run this on repositories in the 'spinnaker' org, not on forks. + if: startsWith(github.repository, 'spinnaker/') + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.ubuntu + platforms: linux/amd64,linux/arm64 + push: true + tags: | + "${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.release_info.outputs.RELEASE_VERSION }}-unvalidated-ubuntu" + "${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.release_info.outputs.RELEASE_VERSION }}-${{ steps.build_variables.outputs.VERSION }}-unvalidated-ubuntu" + - name: Build and publish slim JRE 11 container image + # Only run this on repositories in the 'spinnaker' org, not on forks. + if: startsWith(github.repository, 'spinnaker/') + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.java11.slim + platforms: linux/amd64,linux/arm64 + push: true + tags: | + "${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.release_info.outputs.RELEASE_VERSION }}-java11-unvalidated" + "${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.release_info.outputs.RELEASE_VERSION }}-java11-unvalidated-slim" + "${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.release_info.outputs.RELEASE_VERSION }}-${{ steps.build_variables.outputs.VERSION }}-java11-unvalidated-slim" + - name: Build and publish ubuntu JRE 11 container image + # Only run this on repositories in the 'spinnaker' org, not on forks. + if: startsWith(github.repository, 'spinnaker/') + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.java11.ubuntu + platforms: linux/amd64,linux/arm64 + push: true + tags: | + "${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.release_info.outputs.RELEASE_VERSION }}-java11-unvalidated-ubuntu" + "${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.release_info.outputs.RELEASE_VERSION }}-${{ steps.build_variables.outputs.VERSION }}-java11-unvalidated-ubuntu" - name: Create release if: steps.release_info.outputs.SKIP_RELEASE == 'false' - uses: softprops/action-gh-release@v1 + uses: softprops/action-gh-release@v2 with: body: | ${{ steps.release_info.outputs.CHANGELOG }} @@ -48,3 +157,11 @@ jobs: prerelease: ${{ steps.release_info.outputs.IS_CANDIDATE }} tag_name: ${{ github.ref }} token: ${{ secrets.GITHUB_TOKEN }} + - name: Pause before dependency bump + run: sleep 900 + - name: Trigger dependency bump workflow + uses: peter-evans/repository-dispatch@v3 + with: + token: ${{ secrets.SPINNAKER_GITHUB_TOKEN }} + event-type: bump-dependencies + client-payload: '{"ref": "${{ github.ref }}", "branch": "${{ env.BRANCH}}"}' diff --git a/.github/workflows/release_info.sh b/.github/workflows/release_info.sh index 0cadf01b..3c3a158a 100755 --- a/.github/workflows/release_info.sh +++ b/.github/workflows/release_info.sh @@ -1,20 +1,24 @@ #!/bin/bash -x -# Only look to the latest release to determine the previous tag -- this allows us to skip unsupported tag formats (like `version-1.0.0`) -export PREVIOUS_TAG=`curl --silent "https://api.github.com/repos/$1/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/'` -echo "PREVIOUS_TAG=$PREVIOUS_TAG" -export NEW_TAG=${GITHUB_REF/refs\/tags\//} +NEW_TAG=${GITHUB_REF/refs\/tags\//} +export NEW_TAG echo "NEW_TAG=$NEW_TAG" -export CHANGELOG=`git log $NEW_TAG...$PREVIOUS_TAG --oneline` +# Glob match previous tags which should be format v1.2.3. Avoids Deck's npm tagging. +PREVIOUS_TAG=$(git describe --abbrev=0 --tags "${NEW_TAG}"^ --match 'v[0-9]*') +export PREVIOUS_TAG +echo "PREVIOUS_TAG=$PREVIOUS_TAG" +CHANGELOG=$(git log "$NEW_TAG"..."$PREVIOUS_TAG" --oneline) +export CHANGELOG echo "CHANGELOG=$CHANGELOG" -#Format the changelog so it's markdown compatible +# Format the changelog so it's markdown compatible CHANGELOG="${CHANGELOG//$'%'/%25}" CHANGELOG="${CHANGELOG//$'\n'/%0A}" CHANGELOG="${CHANGELOG//$'\r'/%0D}" # If the previous release tag is the same as this tag the user likely cut a release (and in the process created a tag), which means we can skip the need to create a release -export SKIP_RELEASE=`[[ "$PREVIOUS_TAG" = "$NEW_TAG" ]] && echo "true" || echo "false"` +SKIP_RELEASE=$([[ "$PREVIOUS_TAG" = "$NEW_TAG" ]] && echo "true" || echo "false") +export SKIP_RELEASE # https://github.com/fsaintjacques/semver-tool/blob/master/src/semver#L5-L14 NAT='0|[1-9][0-9]*' @@ -28,8 +32,10 @@ SEMVER_REGEX="\ (\\+${FIELD}(\\.${FIELD})*)?$" # Used in downstream steps to determine if the release should be marked as a "prerelease" and if the build should build candidate release artifacts -export IS_CANDIDATE=`[[ $NEW_TAG =~ $SEMVER_REGEX && ! -z ${BASH_REMATCH[4]} ]] && echo "true" || echo "false"` +IS_CANDIDATE=$([[ $NEW_TAG =~ $SEMVER_REGEX && -n ${BASH_REMATCH[4]} ]] && echo "true" || echo "false") +export IS_CANDIDATE # This is the version string we will pass to the build, trim off leading 'v' if present -export RELEASE_VERSION=`[[ $NEW_TAG =~ $SEMVER_REGEX ]] && echo "${NEW_TAG:1}" || echo "${NEW_TAG}"` +RELEASE_VERSION=$([[ $NEW_TAG =~ $SEMVER_REGEX ]] && echo "${NEW_TAG:1}" || echo "${NEW_TAG}") +export RELEASE_VERSION echo "RELEASE_VERSION=$RELEASE_VERSION" diff --git a/Dockerfile.compile b/Dockerfile.compile new file mode 100644 index 00000000..68b3535c --- /dev/null +++ b/Dockerfile.compile @@ -0,0 +1,8 @@ +FROM ubuntu:jammy +RUN apt-get update && apt-get install -y \ + openjdk-11-jdk \ + && rm -rf /var/lib/apt/lists/* +LABEL maintainer="sig-platform@spinnaker.io" +ENV GRADLE_USER_HOME /workspace/.gradle +ENV GRADLE_OPTS -Xmx4g +CMD ./gradlew --no-daemon swabbie-web:installDist -x test diff --git a/Dockerfile.java11.slim b/Dockerfile.java11.slim new file mode 100644 index 00000000..b02aaae3 --- /dev/null +++ b/Dockerfile.java11.slim @@ -0,0 +1,10 @@ +FROM alpine:3.16 +LABEL maintainer="sig-platform@spinnaker.io" +RUN apk --no-cache add --update bash curl openjdk11-jre +RUN addgroup -S -g 10111 spinnaker +RUN adduser -S -G spinnaker -u 10111 spinnaker +COPY swabbie-web/build/install/swabbie /opt/swabbie +RUN mkdir -p /opt/swabbie/plugins && chown -R spinnaker:nogroup /opt/swabbie/plugins +USER spinnaker +HEALTHCHECK CMD curl --fail http://localhost:8092/health +CMD ["/opt/swabbie/bin/swabbie"] diff --git a/Dockerfile.java11.ubuntu b/Dockerfile.java11.ubuntu new file mode 100644 index 00000000..7ee58447 --- /dev/null +++ b/Dockerfile.java11.ubuntu @@ -0,0 +1,9 @@ +FROM ubuntu:jammy +LABEL maintainer="sig-platform@spinnaker.io" +RUN apt-get update && apt-get -y install curl openjdk-11-jre-headless wget +RUN adduser --system --uid 10111 --group spinnaker +COPY swabbie-web/build/install/swabbie /opt/swabbie +RUN mkdir -p /opt/swabbie/plugins && chown -R spinnaker:nogroup /opt/swabbie/plugins +USER spinnaker +HEALTHCHECK CMD curl --fail http://localhost:8092/health +CMD ["/opt/swabbie/bin/swabbie"] diff --git a/Dockerfile.slim b/Dockerfile.slim new file mode 100644 index 00000000..f3f7b432 --- /dev/null +++ b/Dockerfile.slim @@ -0,0 +1,10 @@ +FROM alpine:3.16 +LABEL maintainer="sig-platform@spinnaker.io" +RUN apk --no-cache add --update bash curl openjdk17-jre +RUN addgroup -S -g 10111 spinnaker +RUN adduser -S -G spinnaker -u 10111 spinnaker +COPY swabbie-web/build/install/swabbie /opt/swabbie +RUN mkdir -p /opt/swabbie/plugins && chown -R spinnaker:nogroup /opt/swabbie/plugins +USER spinnaker +HEALTHCHECK CMD curl --fail http://localhost:8092/health +CMD ["/opt/swabbie/bin/swabbie"] diff --git a/Dockerfile.ubuntu b/Dockerfile.ubuntu new file mode 100644 index 00000000..949e6990 --- /dev/null +++ b/Dockerfile.ubuntu @@ -0,0 +1,9 @@ +FROM ubuntu:jammy +LABEL maintainer="sig-platform@spinnaker.io" +RUN apt-get update && apt-get -y install curl openjdk-17-jre-headless wget +RUN adduser --system --uid 10111 --group spinnaker +COPY swabbie-web/build/install/swabbie /opt/swabbie +RUN mkdir -p /opt/swabbie/plugins && chown -R spinnaker:nogroup /opt/swabbie/plugins +USER spinnaker +HEALTHCHECK CMD curl --fail http://localhost:8092/health +CMD ["/opt/swabbie/bin/swabbie"] diff --git a/build.gradle b/build.gradle index cb41408d..129adcab 100644 --- a/build.gradle +++ b/build.gradle @@ -17,37 +17,39 @@ plugins { id "io.spinnaker.project" version "$spinnakerGradleVersion" apply false id "org.jetbrains.kotlin.jvm" version "$kotlinVersion" apply false - id "org.jetbrains.dokka" version "1.7.20" apply false + id "io.gitlab.arturbosch.detekt" version "1.17.1" apply false + id "org.jetbrains.dokka" version "1.9.20" apply false } allprojects { apply plugin: "io.spinnaker.project" + group = "io.spinnaker.swabbie" +} + +subprojects { if (korkVersion.endsWith("-SNAPSHOT")) { repositories { mavenLocal() } } - group = "io.spinnaker.swabbie" - - configurations.all { - exclude group: "javax.servlet", module: "servlet-api" - exclude group: "org.slf4j", module: "slf4j-log4j12" - exclude group: "org.slf4j", module: "slf4j-simple" - } - if (name != "swabbie-bom") { - apply plugin: "java" + apply plugin: "java-library" apply from: "$rootDir/gradle/kotlin.gradle" apply from: "$rootDir/gradle/junit5.gradle" apply from: "$rootDir/gradle/license.gradle" apply from: "$rootDir/gradle/dokka.gradle" dependencies { - api(platform("io.spinnaker.kork:kork-bom:$korkVersion")) + implementation(enforcedPlatform("io.spinnaker.kork:kork-bom:$korkVersion")) annotationProcessor(platform("io.spinnaker.kork:kork-bom:$korkVersion")) - annotationProcessor("org.springframework.boot:spring-boot-configuration-processor") + testAnnotationProcessor(platform("io.spinnaker.kork:kork-bom:$korkVersion")) + implementation("org.slf4j:slf4j-api") + } + + configurations.all { + exclude group: "javax.servlet", module: "servlet-api" } test { @@ -67,3 +69,5 @@ allprojects { } } } + +defaultTasks ":swabbie-web:run" diff --git a/docs/swabbie.yml b/docs/swabbie.yml index 96e99917..c9321b15 100644 --- a/docs/swabbie.yml +++ b/docs/swabbie.yml @@ -1,5 +1,5 @@ server: - port: 8088 + port: 8092 orca: baseUrl: # orca url diff --git a/gradle.properties b/gradle.properties index 3c7e1f5a..c4a3c481 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -korkVersion=7.216.0 +korkVersion=7.224.0 kotlinVersion=1.6.21 org.gradle.parallel=true spinnakerGradleVersion=8.32.1 diff --git a/gradle/dokka.gradle b/gradle/dokka.gradle index 5dd8f37c..5e80a578 100644 --- a/gradle/dokka.gradle +++ b/gradle/dokka.gradle @@ -1,8 +1,6 @@ apply plugin: "org.jetbrains.dokka" -tasks.named("dokkaHtml").configure { - outputDirectory.set(new File("$buildDir/javadoc")) - +dokkaHtml { dokkaSourceSets { configureEach { jdkVersion.set(11) diff --git a/gradle/junit5.gradle b/gradle/junit5.gradle index 09ee713b..534ff399 100644 --- a/gradle/junit5.gradle +++ b/gradle/junit5.gradle @@ -21,8 +21,8 @@ dependencies { testImplementation "org.junit.jupiter:junit-jupiter-api" testImplementation "org.junit.jupiter:junit-jupiter-params" - testRuntime "org.junit.platform:junit-platform-launcher" - testRuntime "org.junit.jupiter:junit-jupiter-engine" + testRuntimeOnly "org.junit.platform:junit-platform-launcher" + testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine" } test { diff --git a/gradle/kotlin.gradle b/gradle/kotlin.gradle index f848bdc9..69fc4eb6 100644 --- a/gradle/kotlin.gradle +++ b/gradle/kotlin.gradle @@ -15,17 +15,18 @@ */ apply plugin: "kotlin" +apply plugin: "io.gitlab.arturbosch.detekt" compileKotlin { kotlinOptions { - languageVersion = "1.4" + languageVersion = "1.6" jvmTarget = "11" } } compileTestKotlin { kotlinOptions { - languageVersion = "1.4" + languageVersion = "1.6" jvmTarget = "11" } } @@ -39,3 +40,18 @@ configurations.all { } } } + +detekt { + parallel = false + config = files("$rootDir/.detekt.yml") + buildUponDefaultConfig = true + ignoreFailures = true + reports { + xml { + enabled = false + } + txt { + enabled = false + } + } +} diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 28ff446a..50832291 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip +networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/settings.gradle b/settings.gradle index a25f9f2e..5c71f28f 100644 --- a/settings.gradle +++ b/settings.gradle @@ -22,8 +22,6 @@ } } -enableFeaturePreview("VERSION_ORDERING_V2") - rootProject.name = 'swabbie' include 'swabbie-test', diff --git a/swabbie-web/config/swabbie.yml b/swabbie-web/config/swabbie.yml new file mode 100644 index 00000000..2a7efec9 --- /dev/null +++ b/swabbie-web/config/swabbie.yml @@ -0,0 +1,14 @@ +server: + port: 8092 + +front50: + baseUrl: ${services.front50.baseUrl:http://localhost:8080} + +orca: + baseUrl: ${services.orca.baseUrl:http://localhost:8083} + +clouddriver: + baseUrl: ${services.clouddriver.baseUrl:http://localhost:7002} + +echo: + baseUrl: ${services.echo.baseUrl:http://localhost:8089}