From 473234478cf1a68c9c9b2c032b89433f5760ddc2 Mon Sep 17 00:00:00 2001 From: Sayali Mohadikar <76010603+sayaliM0412@users.noreply.github.com> Date: Fri, 22 Sep 2023 08:52:45 -0700 Subject: [PATCH] DAT-15851 (#80) * add ci and ci-report yml files as reusable workflow * Update README.md for ci and ci-report.yml --------- Co-authored-by: Sayali M --- .github/workflows/ci-report.yml | 51 +++++++++++ .github/workflows/ci.yml | 148 ++++++++++++++++++++++++++++++++ README.md | 4 +- 3 files changed, 202 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/ci-report.yml create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci-report.yml b/.github/workflows/ci-report.yml new file mode 100644 index 00000000..91ecde73 --- /dev/null +++ b/.github/workflows/ci-report.yml @@ -0,0 +1,51 @@ +name: 'Continuous Integration - Report' + +on: + push: + branches: + - main + +jobs: + test-report: + name: Report Test Results + runs-on: ubuntu-latest + if: github.event.workflow_run.conclusion != 'skipped' + + steps: + - uses: actions/checkout@v3 + + - name: Download and Extract Artifacts + env: + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + run: | + mvn -B liquibase-sdk:download-snapshot-artifacts \ + -Dliquibase.sdk.repo=${{ github.repository }} \ + -Dliquibase.sdk.runId=${{ github.event.workflow_run.id }} \ + -Dliquibase.sdk.downloadDirectory=artifacts \ + -Dliquibase.sdk.artifactPattern=* \ + -Dliquibase.sdk.unzipArtifacts=true + + - name: Publish Unit Test Results + uses: EnricoMi/publish-unit-test-result-action@v2 + with: + commit: ${{ github.event.workflow_run.head_sha }} + event_file: artifacts/Event File/event.json + event_name: ${{ github.event.workflow_run.event }} + junit_files: "artifacts/test-reports-*/**/*.xml" + + build-testing-comment: + name: Add Build Testing Comment + runs-on: ubuntu-latest + if: github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch != 'main' + + steps: + - uses: actions/checkout@v3 + + - name: Create "BUILD_TESTING" comment + env: + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + run: | + mvn -B liquibase-sdk:set-pull-request-comment \ + -Dliquibase.sdk.repo=${{ github.repository }} \ + -Dliquibase.sdk.pr.newComment=BUILD_TESTING \ + -Dliquibase.sdk.pr.definition=${{ github.event.workflow_run.head_branch }} \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..ec764c2c --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,148 @@ +name: Continuous Integration + +# Job will run nightly at 02:05 EDT / 01:05 CDT +# Time below is UTC +on: + workflow_call: + +jobs: + build: + name: Build & Package + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Set up JDK 17 + uses: actions/setup-java@v2 + with: + java-version: 17 + distribution: 'temurin' + cache: 'maven' + + - name: Install liquibase-core 0-SNAPSHOT + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: mvn -B clean liquibase-sdk:install-snapshot -Dliquibase.sdk.branchSearch=MATCHING_BRANCHES,master + + - name: Build and Package + run: mvn -B dependency:go-offline clean package -DskipTests=true + + - name: Save Artifacts + uses: actions/upload-artifact@v2 + with: + name: liquibase-bigquery-artifacts + path: | + target/*.jar + + - name: Save Event File + uses: actions/upload-artifact@v3 + with: + name: Event File + path: ${{ github.event_path }} + + - name: Build Cache + uses: actions/cache@v3.0.5 + with: + key: build-${{ github.run_number }}-${{ github.run_attempt }} + path: | + **/target/** + ~/.m2/repository/org/liquibase/ + + unit-test: + name: Test Java ${{ matrix.java }} + runs-on: ubuntu-latest + needs: build + + strategy: + fail-fast: false + matrix: + java: [ 8, 11, 17, 18 ] + + steps: + - uses: actions/checkout@v3 + + - name: Set up JDK ${{ matrix.java }} + uses: actions/setup-java@v2 + with: + java-version: ${{ matrix.java }} + distribution: 'temurin' + cache: 'maven' + + - name: Build Cache + uses: actions/cache@v3.0.5 + with: + key: build-${{ github.run_number }}-${{ github.run_attempt }} + path: | + **/target/** + ~/.m2/repository/org/liquibase/ + + - name: Run Tests + run: mvn -B jacoco:prepare-agent surefire:test + + - name: Archive Test Results + if: ${{ always() }} + uses: actions/upload-artifact@v2 + with: + name: test-reports-jdk-${{ matrix.java }} + path: | + **/target/surefire-reports + **/target/jacoco.exec + + integration-test: + name: Test Harness for BigQuery + needs: build + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Set up JDK + uses: actions/setup-java@v2 + with: + java-version: 17 + distribution: 'temurin' + cache: 'maven' + + - name: Build Cache + uses: actions/cache@v3.0.5 + with: + key: build-${{ github.run_number }}-${{ github.run_attempt }} + path: | + **/target/** + ~/.m2/repository/org/liquibase/ + + - name: Run Test Harness Tests + run: mvn -B jacoco:prepare-agent surefire:test -Dit.test=LiquibaseHarnessSuiteIT + + - name: Archive Test Results + if: ${{ always() }} + uses: actions/upload-artifact@v2 + with: + name: test-reports-bigquery-integration + path: | + **/target/surefire-reports + **/target/jacoco.exec + + dependabot: + name: Merge dependabot + runs-on: ubuntu-latest + needs: integration-test + permissions: + contents: write + pull-requests: write + if: ${{ github.actor == 'dependabot[bot]' }} + + steps: + - name: Dependabot metadata + id: dependabot-metadata + uses: dependabot/fetch-metadata@v1.3.1 + + - name: Approve patch and minor updates + if: ${{steps.dependabot-metadata.outputs.update-type == 'version-update:semver-patch' || steps.dependabot-metadata.outputs.update-type == 'version-update:semver-minor'}} + run: | + gh pr merge --auto --merge "$PR_URL" + gh pr review $PR_URL --approve -b "I'm **approving** this pull request because **it includes a patch or minor update**" + env: + PR_URL: ${{github.event.pull_request.html_url}} + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} diff --git a/README.md b/README.md index d7171c67..9af791a0 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,8 @@ Please review the below table of reusable workflows and their descriptions: | `sonar-test-scan.yml` | Code Coverage Scan for unit and integration tests | | `sonar-push.yml` | Same as PR job, but for pushes to main. Does not require branch name parameter | | `snyk-nightly.yml` | Nightly Security Scans | +| `ci.yml` | Run unit, integrations tests against the new liquibase SNAPSHOT | +| `ci-report.yml` | Extract results obtained from ci.yml and generate a report | | various shell scripts | helper scripts for getting the draft release, signing artifacts, and uploading assets | ## Requirements @@ -435,4 +437,4 @@ Here the modules we want to generate and aggregate test reports must be specifie -``` \ No newline at end of file +```