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

ci: unify castor and mercury workflows #61

Merged
merged 1 commit into from Oct 14, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/actions/aggregate-test-reports/action.yml
@@ -0,0 +1,23 @@
name: "Aggregate test reports"
description: "Aggregates all TEST-*.xml reports for all subprojects in one directory"
inputs:
tests-dir:
description: "Top-level directory to search for reports. Defaults to current dir."
required: false
default: "."
reports-dir:
description: "Name of the directory that contains test reports"
required: false
default: "test-reports"
runs:
using: "composite"
steps:
- name: "Aggregate reports"
shell: bash
run: |
for REPORTS in $(find ${{ inputs.tests-dir }} -name ${{ inputs.reports-dir }} ); do
PROJECT="${REPORTS%/target/*}"
DEST="${{ inputs.tests-dir }}/target/${{ inputs.reports-dir }}/${PROJECT}"
mkdir -p ${DEST}
cp -r "${REPORTS}" "${DEST}"
done
20 changes: 15 additions & 5 deletions .github/workflows/castor.yml
Expand Up @@ -28,7 +28,6 @@ on:

# Global environment variables for all jobs
env:
JAVA_VERSION: openjdk@1.11
ATALA_GITHUB_ACTOR: ${{ secrets.ATALA_GITHUB_ACTOR }}
ATALA_GITHUB_TOKEN: ${{ secrets.ATALA_GITHUB_TOKEN }}

Expand All @@ -40,10 +39,13 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Scala
uses: olafurpg/setup-scala@v11
- name: Setup Java and Scala
uses: olafurpg/setup-scala@v13
with:
java-version: ${{ env.JAVA_VERSION }}
java-version: openjdk@1.11

- name: Cache sbt
uses: coursier/cache-action@v6.3

# Step to be removed after adding publishing of shared module
- name: Build shared module
Expand All @@ -59,9 +61,17 @@ jobs:
- name: Build and test Castor
run: cd castor/lib && sbt test

- name: Aggregate test reports
if: always()
uses: ./.github/actions/aggregate-test-reports
with:
tests-dir: "castor/lib"

- name: Publish test results
# Publish even if the previous test step fails
if: always()
uses: EnricoMi/publish-unit-test-result-action@v2
with:
junit_files: "castor/lib/core/target/test-reports/TEST-*.xml"
junit_files: "castor/lib/target/test-reports/**/TEST-*.xml"
comment_title: "Castor Test Results"
check_name: "Castor Test Results"
43 changes: 0 additions & 43 deletions .github/workflows/mercury-ci.yml

This file was deleted.

63 changes: 63 additions & 0 deletions .github/workflows/mercury.yml
@@ -0,0 +1,63 @@
name: Mercury testing workflow

# Cancel previously running workflows if new commit pushed to the branch
# this will help to push fixes earlier and stop previous workflows
concurrency:
group: ${{ github.head_ref }}${{ github.ref }}-mercury
cancel-in-progress: true

on:
# Run with every push to `main` branch
# Run with each PR opened vs Mercury
pull_request:
paths:
- ".github/workflows/mercury.yml"
- "mercury/**"
push:
branches:
- "main"
paths:
- ".github/workflows/mercury.yml"
- "mercury/**"

defaults:
run:
shell: bash
working-directory: "mercury/prism-mediator"

jobs:
build-and-test-mercury:
name: "Build and test Mercury"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Java and Scala
uses: olafurpg/setup-scala@v13
with:
java-version: openjdk@1.11

- name: Cache sbt
uses: coursier/cache-action@v6.3

- name: Run Scala formatter
run: sbt scalafmtCheckAll

- name: Build and test Mercury
run: sbt test

- name: Aggregate test reports
if: always()
uses: ./.github/actions/aggregate-test-reports
with:
tests-dir: "mercury/prism-mediator"

- name: Publish test results
# Publish even if the test step fails
if: always()
uses: EnricoMi/publish-unit-test-result-action@v2
with:
junit_files: "mercury/prism-mediator/target/test-reports/**/TEST-*.xml"
comment_title: "Mercury Test Results"
check_name: "Mercury Test Results"