Skip to content

Commit

Permalink
DAT-15851 (#80)
Browse files Browse the repository at this point in the history
* add ci and ci-report yml files as reusable workflow

* Update README.md for ci and ci-report.yml

---------

Co-authored-by: Sayali M <sayali@Sayalis-MacBook-Pro>
  • Loading branch information
sayaliM0412 and Sayali M authored Sep 22, 2023
1 parent 871793d commit 4732344
Show file tree
Hide file tree
Showing 3 changed files with 202 additions and 1 deletion.
51 changes: 51 additions & 0 deletions .github/workflows/ci-report.yml
Original file line number Diff line number Diff line change
@@ -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 }}
148 changes: 148 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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/[email protected]
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/[email protected]
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/[email protected]

- 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}}
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -435,4 +437,4 @@ Here the modules we want to generate and aggregate test reports must be specifie
</plugin>
</plugins>
</build>
```
```

0 comments on commit 4732344

Please sign in to comment.