Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitHub actions #481

Merged
merged 12 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/actions/e2e-composite/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: 'End-to-end testing composite'
description: 'Run MDM-Core End-to-end functional tests'
inputs:
package:
description: 'The package to be tested'
required: true
runs:
using: 'composite'
steps:
- name: 'E2E Functional Test: ${{ inputs.package }}'
shell: bash
run: './gradlew -Dgradle.test.package=${{ inputs.package }} :mdm-testing-functional:integrationTest'

- name: 'E2E Functional Test Report: ${{ inputs.package }}'
uses: dorny/test-reporter@v1
if: success() || failure()
with:
name: 'E2E Functional Test Results: ${{ inputs.package }}'
path: mdm-testing-functional/build/test-results/${{ inputs.package }}/*.xml
reporter: java-junit
list-suites: 'failed'
list-tests: 'failed'
248 changes: 248 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,248 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle

name: Java CI with Gradle

on:
push:
branches: [ "**" ]
pull_request:
branches: [ "**" ]

permissions:
contents: read
actions: read
checks: write
security-events: write

jobs:
build:

runs-on: ubuntu-latest

env:
GRADLE_OPTS: -Dorg.gradle.jvmargs="-XX:MaxMetaspaceSize=1g -Xmx1024m"

services:
postgres:
image: postgres
env:
POSTGRES_USER: sandbox
POSTGRES_DB: sandbox
POSTGRES_PASSWORD: sandbox
options: >-
--health-cmd pg_isready
--health-interval 1s
--health-timeout 5s
--health-retries 50
ports:
- 5432:5432

steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
cache-disabled: true
build-scan-publish: true
build-scan-terms-of-use-url: "https://gradle.com/terms-of-service"
build-scan-terms-of-use-agree: "yes"

- name: Core gradle info
run: |
./gradlew -v
./gradlew jvmArgs sysProps

- name: Mdm-core grails info
working-directory: ./mdm-core
run: |
./grailsw -v

- name: License header check
run: |
./gradlew license

- name: Flyway migration check
run: |
./gradlew verifyFlywayMigrationVersions


- name: Unit Tests
run: ./gradlew test --no-daemon --stacktrace -Duser.language=en -Duser.country=GB

- name: Unit Test Report
uses: dorny/test-reporter@v1
if: success() || failure()
with:
name: Unit Test Results
path: '**/build/test-results/**/*.xml'
reporter: java-junit
list-tests: 'failed'

- name: Parallel Integration Tests
run: |
./gradlew -Dgradle.integrationTest=true -Dgradle.parallel=true \
mdm-core:integrationTest \
mdm-plugin-authentication-apikey:integrationTest \
mdm-plugin-authentication-basic:integrationTest \
mdm-plugin-dataflow:integrationTest \
mdm-plugin-datamodel:integrationTest \
mdm-plugin-email-proxy:integrationTest \
mdm-plugin-federation:integrationTest \
mdm-plugin-profile:integrationTest \
mdm-plugin-referencedata:integrationTest \
mdm-plugin-terminology:integrationTest
# mdm-plugin-security:integrationTest // Is commented out in Jenkins - not sure why

- name: Parallel Integration Test Report
uses: dorny/test-reporter@v1
if: success() || failure()
with:
name: Parallel Integration Test Results
path: '**/build/test-results/parallelIntegrationTest/*.xml'
reporter: java-junit
list-tests: 'failed'

- name: Non-Parallel Integration Tests
run: |
./gradlew -Dgradle.integrationTest=true -Dgradle.nonParallel=true \
mdm-core:integrationTest \
mdm-plugin-authentication-apikey:integrationTest \
mdm-plugin-authentication-basic:integrationTest \
mdm-plugin-dataflow:integrationTest \
mdm-plugin-datamodel:integrationTest \
mdm-plugin-email-proxy:integrationTest \
mdm-plugin-federation:integrationTest \
mdm-plugin-profile:integrationTest \
mdm-plugin-referencedata:integrationTest \
mdm-plugin-terminology:integrationTest \
mdm-security:integrationTest


- name: Non-Parallel Integration Test Report
uses: dorny/test-reporter@v1
if: success() || failure()
with:
name: Non-Parallel Integration Test Results
path: '**/build/test-results/nonParallelIntegrationTest/*.xml'
reporter: java-junit
list-tests: 'failed'

- name: End-to-end testing - core
uses: ./.github/actions/e2e-composite
with:
package: core

- name: End-to-end testing - security
uses: ./.github/actions/e2e-composite
with:
package: security

- name: End-to-end testing - authentication
uses: ./.github/actions/e2e-composite
with:
package: authentication

- name: End-to-end testing - datamodel
uses: ./.github/actions/e2e-composite
with:
package: datamodel

- name: End-to-end testing - terminology
uses: ./.github/actions/e2e-composite
with:
package: terminology

- name: End-to-end testing - referencedata
uses: ./.github/actions/e2e-composite
with:
package: referencedata

- name: End-to-end testing - profile
uses: ./.github/actions/e2e-composite
with:
package: profile

- name: End-to-end testing - dataflow
uses: ./.github/actions/e2e-composite
with:
package: dataflow

- name: End-to-end testing - federation
uses: ./.github/actions/e2e-composite
with:
package: federation

- name: End-to-end testing - facet
uses: ./.github/actions/e2e-composite
with:
package: facet

- name: End-to-end testing - versionedfolder
uses: ./.github/actions/e2e-composite
with:
package: versionedfolder

# - name: Archive test report
# if: always()
# uses: actions/upload-artifact@v3
# with:
# name: test-report
# path: '**/build/test-results/**/*.xml'

- name: MegaLinter
uses: oxsecurity/megalinter/flavors/ci_light@v7
env:
# All available variables are described in documentation
# https://megalinter.io/configuration/
VALIDATE_ALL_CODEBASE: true
ENABLE_LINTERS: GROOVY_NPM_GROOVY_LINT
LINTER_RULES_PATH: 'config/codenarc'
DISABLE_ERRORS: true #Flag to have the linter complete with exit code 0 even if errors were detected.
SARIF_REPORTER: true

# This is currently too big for the security tab
# - name: Upload MegaLinter scan results to GitHub Security tab
# if: success() || failure()
# uses: github/codeql-action/upload-sarif@v2
# with:
# sarif_file: 'megalinter-reports/megalinter-report.sarif'


# Upload MegaLinter artifacts
# - name: Archive lint reports
# if: ${{ success() }} || ${{ failure() }}
# uses: actions/upload-artifact@v3
# with:
# name: MegaLinter reports
# path: |
# megalinter-reports
# mega-linter.log

- name: Publish Snapshot to Mauro Snapshot Repository
if: success() && github.ref == 'refs/heads/develop'
run: |
./gradlew --stacktrace -PMauroSnapshotRepositoryUsername=${{secrets.MAURO_SNAPSHOT_REPOSITORY_USERNAME}} -PMauroSnapshotRepositoryPassword=${{secrets.MAURO_SNAPSHOT_REPOSITORY_PASSWORD}} publishAllPublicationsToMauroSnapshotRepositoryRepository


- name: Send a stream message
if: success() || failure()
uses: zulip/github-actions-zulip/send-message@v1
with:
api-key: ${{ secrets.ZULIP_API_KEY }}
email: "[email protected]"
organization-url: "https://maurodatamapper.zulipchat.com"
to: "build/github-actions"
type: "stream"
topic: "${{github.repository}}"
content: "${{ job.status == 'success' && ':check_mark:' || ':cross_mark:' }} ${{github.repository}} : **${{github.ref}}**\nGitHub Actions build result: **${{ job.status }}**\n${{ github.event.pull_request.html_url || github.event.head_commit.url }}"
29 changes: 22 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ import java.util.concurrent.TimeUnit
buildscript {
repositories {
mavenLocal()
maven {url 'https://jenkins.cs.ox.ac.uk/artifactory/plugins-snapshot'}
maven {url 'https://jenkins.cs.ox.ac.uk/artifactory/plugins-release'}

mavenCentral()
maven {url 'https://mauro-repository.com/libs-release-local'}
maven {url 'https://mauro-repository.com/plugins-snapshot-local'}
maven {url 'https://mauro-repository.com/plugins-release-local'}
maven {url 'https://repo.gradle.org/gradle/libs-releases/'}
maven {url 'https://plugins.gradle.org/m2/'}
}
dependencies {
classpath "uk.ac.ox.softeng.maurodatamapper.gradle:mdm-gradle-plugin:$mdmGradlePluginVersion"
classpath "uk.ac.ox.softeng.maurodatamapper.gradle:mdm-gradle-plugin:$mdmGradlePluginVersion"
classpath "org.maurodata:mdm-gradle-plugin:$mdmGradlePluginVersion"
}
configurations.all {
// check for updates every build
Expand Down Expand Up @@ -297,7 +299,7 @@ afterEvaluate {
Massive hack to solve parallel task running for assetCompile task
Make sure that each task mustRunAfter another assetCompile task, this ensures none of them can run at the same time
We have to allow for project dependencies so make sure thats accounted for manually
*/
*/
List<Task> assetCompileTasks = it.getTasksByName('assetCompile', true).toList().sort {it.path}

Task coreTask = assetCompileTasks.find {it.path.startsWith(':mdm-core')}
Expand Down Expand Up @@ -337,4 +339,17 @@ FileCollection findNonParallelTestFiles(Project project) {
!f.name.find(/FunctionalSpec/) &&
f.text.find(/@Tag\('non-parallel'\)/)
}
}
}

publishing {
repositories {
maven {
name = "MauroSnapshotRepository"
url = "https://mauro-repository.com/libs-snapshot-local"
credentials(PasswordCredentials)
authentication {
basic(BasicAuthentication)
}
}
}
}
5 changes: 2 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ group=uk.ac.ox.softeng.maurodatamapper
# Gradle
gradleVersion=7.3.3
org.gradle.jvmargs=-Dfile.encoding=UTF-8 -Xmx2g
org.gradle.parallel=true
org.gradle.parallel=false
org.gradle.caching=true
# Code
sourceCompatibility=17
targetCompatibility=17
# Deployment & Build
artifactory_contextUrl=https://jenkins.cs.ox.ac.uk/artifactory
mdmGradlePluginVersion=1.3.0
mdmGradlePluginVersion=8.0.1
# Explode all plugins
exploded=true
# Grails
Expand Down
16 changes: 10 additions & 6 deletions mdm-bom/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
buildscript {
repositories {
mavenLocal()
maven {url "https://jenkins.cs.ox.ac.uk/artifactory/plugins-snapshot"}
maven {url "https://jenkins.cs.ox.ac.uk/artifactory/plugins-release"}

mavenCentral()
maven {url 'https://mauro-repository.com/libs-release-local'}
maven {url 'https://mauro-repository.com/plugins-snapshot-local'}
maven {url 'https://mauro-repository.com/plugins-release-local'}
maven {url 'https://repo.gradle.org/gradle/libs-releases/'}
maven {url 'https://plugins.gradle.org/m2/'}
}
dependencies {
classpath "uk.ac.ox.softeng.maurodatamapper.gradle:mdm-gradle-plugin:$mdmGradlePluginVersion"
classpath "org.maurodata:mdm-gradle-plugin:$mdmGradlePluginVersion"
}
}

Expand All @@ -20,8 +23,9 @@ apply plugin: 'ox.softeng.ox-brc-artifactory'

repositories {
mavenLocal()
maven {url 'https://jenkins.cs.ox.ac.uk/artifactory/libs-snapshot'}
maven {url 'https://jenkins.cs.ox.ac.uk/artifactory/libs-release'}
mavenCentral()
maven {url 'https://mauro-repository.com/libs-snapshot-local'}
maven {url 'https://mauro-repository.com/libs-release-local'}
}

publishing {
Expand Down
Loading
Loading