From 89c205a6396ee0dd2089ff6b989e362a63053698 Mon Sep 17 00:00:00 2001 From: cleverchuk Date: Wed, 2 Oct 2024 14:50:44 -0400 Subject: [PATCH] NH-86008: update pipeline configuration file --- .circleci/config.yml | 193 ------------------------- .circleci/images/Dockerfile | 10 -- {.circleci => .github}/m2/settings.xml | 4 +- .github/workflows/maven.yml | 50 ++++--- .github/workflows/push.yml | 90 ++++++++++++ pom.xml | 2 +- 6 files changed, 123 insertions(+), 226 deletions(-) delete mode 100644 .circleci/config.yml delete mode 100644 .circleci/images/Dockerfile rename {.circleci => .github}/m2/settings.xml (83%) create mode 100644 .github/workflows/push.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index e5e7231c..00000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,193 +0,0 @@ -version: 2.1 # use CircleCI 2.1 - -orbs: - ghas: solarwinds-cloud/ghas@0.1.1 - -executors: - java: - resource_class: xlarge - parameters: - tag: - type: string - default: 8-jdk-hotspot - docker: - - image: 377069709311.dkr.ecr.us-east-1.amazonaws.com/base_ci_build:<< parameters.tag >> - aws_auth: - aws_access_key_id: $ECR_AWS_ACCESS_KEY_ID - aws_secret_access_key: $ECR_AWS_SECRET_ACCESS_KEY - working_directory: ~/repo - environment: - PROJECT_NAME: joboe - SLACK_NOTIFY_CHANNEL: "#chubi-test" - EMOJI: ":circle-pass:" - MAVEN_OPTS: -Xms2g -Xmx3g -Dmaven.resolver.transport=wagon - -commands: - cacheit: - steps: - - run: - name: generate cache checksum - command: find . -name pom.xml | sort | xargs -n 1 cat > /tmp/maven_cached_poms - - restore_cache: - keys: - - maven-repo-v2-{{ .Branch }}-{{ checksum "/tmp/maven_cached_poms" }} - - maven-repo-v2-{{ .Branch }}- - - maven-repo-v2- - - run: mvn -q -s .circleci/m2/settings.xml install -DskipTests - - save_cache: - paths: - - ~/.m2/repository - key: maven-repo-v2-{{ .Branch }}-{{ checksum "/tmp/maven_cached_poms" }} - -jobs: - test: - executor: java - steps: # a collection of executable commands - - checkout # check out source code to working directory - - cacheit - - run: - name: Run maven verify - command: mvn -s .circleci/m2/settings.xml clean verify - - store_artifacts: # uploads the test coverage report - path: core/target/coverage-report - - store_test_results: - path: core/target/surefire-reports - - run: - name: Check shading(core) - command: | - VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) - code=0 - for path in $(jar tf "core/target/core-$VERSION.jar" | grep -E -v '^((com/solarwinds|META))') - do - PACKAGE=$(echo "$path" | awk -F/ '{print $2}') - if [ -n "$PACKAGE" ]; then - echo "Package ($path) is not shaded" - code=1 - fi - done - exit $code - - run: - name: Check shading(metric) - command: | - VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) - code=0 - for path in $(jar tf "metrics/target/metrics-$VERSION.jar" | grep -E -v '^((com/solarwinds|META))') - do - PACKAGE=$(echo "$path" | awk -F/ '{print $2}') - if [ -n "$PACKAGE" ]; then - echo "Package ($path) is not shaded" - code=1 - fi - done - exit $code - deploy: - executor: java - steps: - - checkout - - cacheit - - run: - name: Deploy snapshot - command: | - VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) - BRANCH=$(echo -n "${CIRCLE_BRANCH}" | sed -e 's/[^0-9a-zA-Z\._\-]/./g' | tr '[:upper:]' '[:lower:]') - COMMIT_HASH="${CIRCLE_SHA1:0:7}" - NEW_VERSION=${VERSION%%-SNAPSHOT}-$BRANCH-$COMMIT_HASH-SNAPSHOT - - mvn versions:set -DnewVersion=$NEW_VERSION - mvn -s .circleci/m2/settings.xml -T 8 deploy -DskipTests - source /ci-scripts/bin/helpers.sh - send_to_slack "A new snapshot is ready \`$NEW_VERSION\`" - release: - executor: java - steps: - - checkout - - cacheit - - run: - name: Check versions - command: mvn versions:use-releases - - run: - name: Configure git for release - command: | - git config user.name "${GITHUB_USERNAME}" - git config user.email "${GITHUB_USERNAME}-github@solarwinds.com" - - run: - name: Rewrite github url for release tagging - command: | - git config --global url."https://${GITHUB_TOKEN}:@github.com/".insteadOf git@github.com: - - run: - name: Perform release - command: | - VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) - VERSION=${VERSION%%-SNAPSHOT} - - curl -f -L \ - -X POST \ - -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer ${GITHUB_TOKEN}"\ - -H "X-GitHub-Api-Version: 2022-11-28" \ - https://api.github.com/repos/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/releases \ - -d '{ - "tag_name":"v'"$VERSION"'", - "name":"v'"$VERSION"'", - "body":"New release: v'"$VERSION"' for the OpenTelemetry custom distro", - "draft":false, - "prerelease":false, - "generate_release_notes":false - }' - - mvn versions:set -DnewVersion=$VERSION - mvn -s .circleci/m2/settings.xml -T 8 deploy -DskipTests - - echo "Current version is $VERSION" - source /ci-scripts/bin/helpers.sh - send_to_slack "A new release is ready \`$VERSION\`" - -workflows: - build_test_release: - jobs: - - test: - context: - - AWS_CIRCLE_CI_BUILD - - solarwinds-cloud-github-read-access - - deploy: - context: - - SLACK_HOOK - - AWS_CIRCLE_CI_BUILD - - solarwinds-cloud-github-write-access - filters: - branches: - ignore: otel - - approve_me: - type: approval - requires: - - test - filters: - branches: - only: otel - - release: - context: - - SLACK_HOOK - - AWS_CIRCLE_CI_BUILD - - solarwinds-cloud-github-write-access - requires: - - approve_me - filters: - branches: - only: otel - - code-scanning: - jobs: - - ghas/codeql: - executor: java - checkout: true - category: joboe-scan - build_steps: - - run: - name: Build project - command: mvn -s .circleci/m2/settings.xml clean install -DskipTests - language: java - suite: security-and-quality - context: - - ghas-code-scanning - - AWS_CIRCLE_CI_BUILD - - solarwinds-cloud-github-write-access \ No newline at end of file diff --git a/.circleci/images/Dockerfile b/.circleci/images/Dockerfile deleted file mode 100644 index 6262f195..00000000 --- a/.circleci/images/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM circleci/openjdk:11.0.2-jdk - -USER root - -RUN set -x -RUN rm -rf /var/lib/apt/lists/* && apt-get update && apt-get install -y openjdk-8-jdk - -USER circleci - -ENV JAVA_1_8_HOME /usr/lib/jvm/java-8-openjdk-amd64 diff --git a/.circleci/m2/settings.xml b/.github/m2/settings.xml similarity index 83% rename from .circleci/m2/settings.xml rename to .github/m2/settings.xml index e72979a8..3650e828 100644 --- a/.circleci/m2/settings.xml +++ b/.github/m2/settings.xml @@ -5,12 +5,12 @@ github-write - lt-global-circleci + ${env.GITHUB_ACTOR} ${env.GITHUB_TOKEN} github-read - lt-global-circleci + ${env.GITHUB_ACTOR} ${env.GITHUB_TOKEN} diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index cba77eca..afc0f7b1 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -1,44 +1,54 @@ # This workflow does the following things: -# 1. build and test the core Joboe libs (core, metrics and dependencies) +# 1. build and test the core Joboe libs (core, metrics, config, logging and sampling) # 2. publish the jars to Github Packages (which can be used by the NightHawk agent at https://github.com/appoptics/opentelemetry-java-instrumentation-custom-distro) # 3. make a **draft** release on Github and upload the jars as artifacts (you may need to publish the release manually after it) # The workflow needs to be triggered manually. (go to the Actions tab in the repo page, choose the workflow and click `Run Workflow`) # The draft release will be named based on the `revision` property in the pom file. For example, if the pom revision is 7.0.4, the release # will be named as "v7.0.4" -name: Build and Publish Core libs with Maven +name: Release on: workflow_dispatch: +permissions: + packages: write + contents: write + id-token: write + jobs: - publish: + release: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - with: - ref: ${{ github.ref_name }} - - name: Set up JDK 8 for Maven running on JDK9+ - id: setup-jdk-8 - uses: actions/setup-java@v1 - with: - java-version: 8.0.112 - - name: Set up JDK 11 for building the Joboe core libs - uses: actions/setup-java@v2 + - uses: actions/checkout@v4 + + - name: Set up JDK 8 + uses: actions/setup-java@v4 with: - java-version: '11' + java-version: 8.0.302 distribution: 'temurin' + - name: Set version env to pom version run: | echo "POM_VERSION=v$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV + - name: Publish package - run: mvn -Dmaven.resolver.transport=wagon --batch-mode deploy + run: | + VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) + NEW_VERSION=${VERSION%%-SNAPSHOT} + + mvn versions:set -DnewVersion=$NEW_VERSION + mvn -s .github/m2/settings.xml -Dmaven.resolver.transport=wagon --batch-mode deploy env: - JAVA_1_8_HOME: "${{ steps.setup-jdk-8.outputs.path }}" GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Release and upload artifacts - run: gh release create ${{ env.POM_VERSION }} --title "${{ env.POM_VERSION }}" --notes "for the OpenTelemetry custom distro" --target ${{ github.ref_name }} --draft core/target/core-*.jar dependencies/target/dependencies-*.jar metrics/target/metrics-*.jar + run: | + gh release create ${{ env.POM_VERSION }} \ + --title "${{ env.POM_VERSION }}" \ + --notes "for the OpenTelemetry custom distro" \ + --target ${{ github.ref_name }} \ + --draft core/target/core-*.jar metrics/target/metrics-*.jar config/target/config-*.jar \ + logging/target/logging-*.jar sampling/target/sampling-*.jar env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml new file mode 100644 index 00000000..811356a8 --- /dev/null +++ b/.github/workflows/push.yml @@ -0,0 +1,90 @@ +name: Push + +on: + push: + +permissions: + packages: write + contents: write + id-token: write + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up JDK 8 + uses: actions/setup-java@v4 + with: + java-version: 8.0.302 + distribution: 'temurin' + + - name: Run maven verify + run: | + mvn -s .github/m2/settings.xml clean verify + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - uses: actions/upload-artifact@v4 + if: always() + with: + path: core/target/coverage-report + name: coverage report + + - uses: actions/upload-artifact@v4 + if: always() + with: + path: core/target/surefire-reports + name: unit test report + + - name: Check shading(core) + run: | + VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) + code=0 + for path in $(jar tf "core/target/core-$VERSION.jar" | grep -E -v '^((com/solarwinds|META))') + do + PACKAGE=$(echo "$path" | awk -F/ '{print $2}') + if [ -n "$PACKAGE" ]; then + echo "Package ($path) is not shaded" + code=1 + fi + done + exit $code + + - name: Check shading(metric) + run: | + VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) + code=0 + for path in $(jar tf "metrics/target/metrics-$VERSION.jar" | grep -E -v '^((com/solarwinds|META))') + do + PACKAGE=$(echo "$path" | awk -F/ '{print $2}') + if [ -n "$PACKAGE" ]; then + echo "Package ($path) is not shaded" + code=1 + fi + done + exit $code + + deploy_snapshot: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up JDK 8 + uses: actions/setup-java@v4 + with: + java-version: 8.0.302 + distribution: 'temurin' + + - name: Deploy snapshot + run: | + VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) + BRANCH=$(echo -n "${GITHUB_REF_NAME}" | sed -e 's/[^0-9a-zA-Z\._\-]/./g' | tr '[:upper:]' '[:lower:]') + GIT_HASH=$(git rev-parse --short "$GITHUB_SHA") + + NEW_VERSION=${VERSION%%-SNAPSHOT}-$BRANCH-$GIT_HASH-SNAPSHOT + mvn versions:set -DnewVersion=$NEW_VERSION + mvn -s .github/m2/settings.xml -T 8 deploy -DskipTests + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/pom.xml b/pom.xml index 5d3ad29f..ba73a7e4 100644 --- a/pom.xml +++ b/pom.xml @@ -122,7 +122,7 @@ github-write GitHub Packages - https://maven.pkg.github.com/solarwinds-cloud/maven-releases + https://maven.pkg.github.com/solarwinds/joboe