From acd64ea4c8ee7acdcb9a3ec3ed520db3fc44047a Mon Sep 17 00:00:00 2001 From: Carlos Roman Date: Tue, 3 Jun 2025 10:19:07 +0100 Subject: [PATCH] Migrate to GitHub Actions --- .circleci/config.yml | 75 ------------------------ .github/workflows/codeql-analysis.yml | 9 +-- .github/workflows/test.yml | 84 +++++++++++++++++++++++++++ README.md | 2 +- 4 files changed, 90 insertions(+), 80 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 .github/workflows/test.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 97ced20e0..000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,75 +0,0 @@ -version: 2 -lint_steps: &lint_steps - steps: - - checkout - - restore_cache: - name: Restore Maven cache - keys: - # when pom.xml file changes, use increasingly general patterns to restore cache - # Linting has own cache as deps not downloaded during test phases. If doesn't exist will - # fall back on any available cache. - - &maven-cache maven-cache-{{ .Branch }}-{{ checksum "pom.xml" }}-lint - - maven-cache-{{ .Branch }}- - - maven-cache- - - run: ./mvnw verify -B -Dhttps.protocols=TLSv1.2 -DskipTests - - save_cache: - key: *maven-cache - paths: - - ~/.m2 -build_steps: &build_steps - steps: - - checkout - - restore_cache: - name: Restore Maven cache - keys: - # when pom.xml file changes, use increasingly general patterns to restore cache - - &maven-cache maven-cache-{{ .Branch }}-{{ checksum "pom.xml" }} - - maven-cache-{{ .Branch }}- - - maven-cache- - - setup_remote_docker - - run: ./mvnw test -B -Dhttps.protocols=TLSv1.2 -Dcheckstyle.skip=true -Dtests.log_level=info -Djdk.attach.allowAttachSelf=true - - save_cache: - when: always # Save even when test fails so we can reuse cache - key: *maven-cache - paths: - - ~/.m2 - - run: - when: on_fail - command: for log in target/surefire-reports/*.txt; do echo "$log ========================" ; cat $log ; done - -jobs: - lint_openjdk8: - docker: - - image: cimg/openjdk:8.0 - <<: *lint_steps - test_openjdk8: - docker: - - image: cimg/openjdk:8.0 - <<: *build_steps - test_openjdk11: - docker: - - image: cimg/openjdk:11.0 - <<: *build_steps - test_openjdk15: - docker: - - image: cimg/openjdk:15.0 - <<: *build_steps - test_openjdk17: - docker: - - image: cimg/openjdk:17.0 - <<: *build_steps - test_openjdk19: - docker: - - image: cimg/openjdk:19.0 - <<: *build_steps - -workflows: - version: 2 - workflow: - jobs: - - lint_openjdk8 - - test_openjdk8 - - test_openjdk11 - - test_openjdk15 - - test_openjdk17 - - test_openjdk19 diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 3283c27b5..04fd9086b 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -29,7 +29,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@v3 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -37,9 +37,10 @@ jobs: # Prefix the list here with "+" to use these queries and those in the config file. # queries: ./path/to/local/query, your-org/your-repo/queries@main - - uses: actions/checkout@v2 + - name: Checkout code + uses: actions/checkout@v4 - name: Set up JDK 8 - uses: actions/setup-java@v2 + uses: actions/setup-java@v4 with: distribution: 'zulu' java-version: '8' @@ -49,4 +50,4 @@ jobs: run: ./mvnw clean compile assembly:single - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@v3 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 000000000..b215d5367 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,84 @@ +name: CI + +on: + push: + pull_request: + +permissions: read-all + +jobs: + lint: + name: Lint (OpenJDK 8) + runs-on: ubuntu-latest + timeout-minutes: 5 + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up JDK 8 + uses: actions/setup-java@v4 + with: + java-version: '8' + distribution: 'temurin' + + - name: Cache Maven packages + uses: actions/cache@v4 + with: + path: ~/.m2 + key: ${{ runner.os }}-m2-${{ github.ref }}-${{ hashFiles('**/pom.xml') }}-lint + restore-keys: | + ${{ runner.os }}-m2-${{ github.ref }}- + ${{ runner.os }}-m2- + + - name: Run lint + run: ./mvnw verify -B -Dhttps.protocols=TLSv1.2 -DskipTests + + test: + name: Test (OpenJDK ${{ matrix.java-version }}) + runs-on: ubuntu-latest + timeout-minutes: 15 + strategy: + matrix: + java-version: + - 8 + - 11 + - 16 + - 17 + - 19 + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up JDK ${{ matrix.java-version }} + uses: actions/setup-java@v4 + with: + java-version: ${{ matrix.java-version }} + distribution: 'temurin' + + - name: Cache Maven packages + uses: actions/cache@v4 + with: + path: ~/.m2 + key: ${{ runner.os }}-m2-${{ github.ref }}-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-m2-${{ github.ref }}- + ${{ runner.os }}-m2- + + - name: Set up Docker + uses: docker/setup-docker-action@v4 + + - name: Run tests + run: ./mvnw test -B -Dhttps.protocols=TLSv1.2 -Dcheckstyle.skip=true -Dtests.log_level=info -Djdk.attach.allowAttachSelf=true + + - name: Show test logs on failure + if: failure() + run: | + echo "Test failed. Showing surefire reports:" + for log in target/surefire-reports/*.txt; do + if [ -f "$log" ]; then + echo "$log ========================" + cat "$log" + fi + done diff --git a/README.md b/README.md index 2010c7492..8d947799b 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Build Status](https://circleci.com/gh/DataDog/jmxfetch.svg?style=svg)](https://app.circleci.com/pipelines/github/DataDog/jmxfetch) +[![Build Status](https://github.com/DataDog/jmxfetch/actions/workflows/test.yml/badge.svg)](https://github.com/DataDog/jmxfetch/actions/workflows/test.yml) # [Change log](https://github.com/DataDog/jmxfetch/blob/master/CHANGELOG.md)