From 7a10054f67b673d016cc1388dd28da32e25a6271 Mon Sep 17 00:00:00 2001 From: abalias Date: Wed, 30 Nov 2022 14:19:24 +0000 Subject: [PATCH] ci(release): add auto deployments for all components with each merge to main (#186) --- .github/workflows/castor.yml | 63 +++++-------------- .github/workflows/iris-client.yml | 67 +++++--------------- .github/workflows/iris-service.yml | 67 +++++--------------- .github/workflows/mercury.yml | 84 +++++-------------------- .github/workflows/pollux.yml | 63 +++++-------------- .github/workflows/prism-agent.yml | 63 +++++-------------- .github/workflows/prism-node-client.yml | 50 +++++---------- .github/workflows/release.yml | 12 +++- .github/workflows/scala-steward.yml | 1 + .github/workflows/scala-unit-tests.yml | 77 +++++++++++++++++++++++ 10 files changed, 198 insertions(+), 349 deletions(-) create mode 100644 .github/workflows/scala-unit-tests.yml diff --git a/.github/workflows/castor.yml b/.github/workflows/castor.yml index ffa2e1934c..589feaf2c9 100644 --- a/.github/workflows/castor.yml +++ b/.github/workflows/castor.yml @@ -6,65 +6,30 @@ concurrency: group: ${{ github.head_ref }}${{ github.ref }}-castor cancel-in-progress: true -# Default shell is `sh` -# which is old, use bourne-again version instead -defaults: - run: - shell: bash - working-directory: castor/lib - on: - # Run with every push to `main` branch - # Run with each PR opened vs Castor push: branches: - - main + - "main" paths: - ".github/workflows/castor.yml" + - ".github/workflows/scala-unit-tests.yml" - "castor/**" pull_request: paths: - ".github/workflows/castor.yml" + - ".github/workflows/scala-unit-tests.yml" - "castor/**" -# Global environment variables for all jobs -env: - GITHUB_TOKEN: ${{ secrets.ATALA_GITHUB_TOKEN }} - ATALA_GITHUB_TOKEN: ${{ secrets.ATALA_GITHUB_TOKEN }} - jobs: build-and-test-castor: - name: "Build and test Castor" - 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 Castor - run: 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/target/test-reports/**/TEST-*.xml" - comment_title: "Castor Test Results" - check_name: "Castor Test Results" + uses: ./.github/workflows/scala-unit-tests.yml + with: + component-name: "Castor" + component-dir: "castor/lib" + secrets: inherit + release: + if: github.event_name == 'push' + uses: ./.github/workflows/release.yml + with: + release-component: "castor/lib"" + secrets: inherit diff --git a/.github/workflows/iris-client.yml b/.github/workflows/iris-client.yml index 84025c6986..eddc4559bf 100644 --- a/.github/workflows/iris-client.yml +++ b/.github/workflows/iris-client.yml @@ -7,62 +7,29 @@ concurrency: cancel-in-progress: true on: - # Run with every push to `main` branch - # Run with each PR opened vs Mercury - pull_request: - paths: - - ".github/workflows/iris-client.yml" - - "iris/client/**" push: branches: - "main" paths: - ".github/workflows/iris-client.yml" + - ".github/workflows/scala-unit-tests.yml" + - "iris/client/**" + pull_request: + paths: + - ".github/workflows/iris-client.yml" + - ".github/workflows/scala-unit-tests.yml" - "iris/client/**" - -env: - GITHUB_TOKEN: ${{ secrets.ATALA_GITHUB_TOKEN }} - ATALA_GITHUB_TOKEN: ${{ secrets.ATALA_GITHUB_TOKEN }} - -defaults: - run: - shell: bash - working-directory: "iris/client/scala-client" jobs: build-and-test-iris-client: - name: "Build and test Iris client" - 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 Iris client - run: sbt test - - - name: Aggregate test reports - if: always() - uses: ./.github/actions/aggregate-test-reports - with: - tests-dir: "iris/client/scala-client" - - - name: Publish test results - # Publish even if the test step fails - if: always() - uses: EnricoMi/publish-unit-test-result-action@v2 - with: - junit_files: "iris/client/scala-client/target/test-reports/**/TEST-*.xml" - comment_title: "Iris Client Test Results" - check_name: "Iris Client Test Results" + uses: ./.github/workflows/scala-unit-tests.yml + with: + component-name: "Iris Client" + component-dir: "iris/client/scala-client" + secrets: inherit + release: + if: github.event_name == 'push' + uses: ./.github/workflows/release.yml + with: + release-component: "iris/client/scala-client" + secrets: inherit diff --git a/.github/workflows/iris-service.yml b/.github/workflows/iris-service.yml index fdce5c5da8..d1e586e3eb 100644 --- a/.github/workflows/iris-service.yml +++ b/.github/workflows/iris-service.yml @@ -7,62 +7,29 @@ concurrency: cancel-in-progress: true on: - # Run with every push to `main` branch - # Run with each PR opened vs Iris service - pull_request: - paths: - - ".github/workflows/iris-service.yml" - - "iris/service/**" push: branches: - "main" paths: - ".github/workflows/iris-service.yml" + - ".github/workflows/scala-unit-tests.yml" + - "iris/service/**" + pull_request: + paths: + - ".github/workflows/iris-service.yml" + - ".github/workflows/scala-unit-tests.yml" - "iris/service/**" - -env: - GITHUB_TOKEN: ${{ secrets.ATALA_GITHUB_TOKEN }} - ATALA_GITHUB_TOKEN: ${{ secrets.ATALA_GITHUB_TOKEN }} - -defaults: - run: - shell: bash - working-directory: "iris/service" jobs: build-and-test-iris-service: - name: "Build and test Iris service" - 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 Iris service - run: sbt test - - - name: Aggregate test reports - if: always() - uses: ./.github/actions/aggregate-test-reports - with: - tests-dir: "iris/service" - - - name: Publish test results - # Publish even if the test step fails - if: always() - uses: EnricoMi/publish-unit-test-result-action@v2 - with: - junit_files: "iris/service/target/test-reports/**/TEST-*.xml" - comment_title: "Iris Service Test Results" - check_name: "Iris Service Test Results" + uses: ./.github/workflows/scala-unit-tests.yml + with: + component-name: "Iris Service" + component-dir: "iris/service" + secrets: inherit + release: + if: github.event_name == 'push' + uses: ./.github/workflows/release.yml + with: + release-component: "iris/service" + secrets: inherit diff --git a/.github/workflows/mercury.yml b/.github/workflows/mercury.yml index 072f04f647..a9922a51a9 100644 --- a/.github/workflows/mercury.yml +++ b/.github/workflows/mercury.yml @@ -7,79 +7,29 @@ concurrency: 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" + - ".github/workflows/scala-unit-tests.yml" + - "mercury/**" + pull_request: + paths: + - ".github/workflows/mercury.yml" + - ".github/workflows/scala-unit-tests.yml" - "mercury/**" - -env: - GITHUB_TOKEN: ${{ secrets.ATALA_GITHUB_TOKEN }} - SBT_PACKAGER: "enable" #just to test it loads - SBT_SCOVERAGE: "enable" - -defaults: - run: - shell: bash - working-directory: "mercury/mercury-library" 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_SCOVERAGE=enable sbt clean coverage test coverageAggregate - - - name: Aggregate test reports - if: always() - uses: ./.github/actions/aggregate-test-reports - with: - tests-dir: "mercury/mercury-library" - - - name: Code coverage report - if: always() - uses: 5monkeys/cobertura-action@master - with: - path: "mercury/mercury-library/target/coverage/coverage-report/cobertura.xml" - report_name: "Mercury Code Coverage" - minimum_coverage: 10 - fail_below_threshold: false - - - name: Artifact coverage HTML - uses: actions/upload-artifact@v2 - if: always() - with: - name: code-coverage-report-mercury - path: "mercury/mercury-library/target/coverage/scoverage-report" - - - 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/mercury-library/target/test-reports/**/TEST-*.xml" - comment_title: "Mercury Test Results" - check_name: "Mercury Test Results" + uses: ./.github/workflows/scala-unit-tests.yml + with: + component-name: "Mercury Lib" + component-dir: "mercury/mercury-library" + secrets: inherit + release: + if: github.event_name == 'push' + uses: ./.github/workflows/release.yml + with: + release-component: "mercury/mercury-library" + secrets: inherit diff --git a/.github/workflows/pollux.yml b/.github/workflows/pollux.yml index 6dd7e24b2c..f414c2c715 100644 --- a/.github/workflows/pollux.yml +++ b/.github/workflows/pollux.yml @@ -6,65 +6,30 @@ concurrency: group: ${{ github.head_ref }}${{ github.ref }}-pollux cancel-in-progress: true -# Default shell is `sh` -# which is old, use bourne-again version instead -defaults: - run: - shell: bash - working-directory: pollux/lib - on: - # Run with every push to `main` branch - # Run with each PR opened vs Pollux push: branches: - - main + - "main" paths: - ".github/workflows/pollux.yml" + - ".github/workflows/scala-unit-tests.yml" - "pollux/**" pull_request: paths: - ".github/workflows/pollux.yml" + - ".github/workflows/scala-unit-tests.yml" - "pollux/**" -# Global environment variables for all jobs -env: - GITHUB_TOKEN: ${{ secrets.ATALA_GITHUB_TOKEN }} - ATALA_GITHUB_TOKEN: ${{ secrets.ATALA_GITHUB_TOKEN }} - jobs: build-and-test-pollux: - name: "Build and test Pollux" - 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 Pollux - run: sbt test - - - name: Aggregate test reports - if: always() - uses: ./.github/actions/aggregate-test-reports - with: - tests-dir: "pollux/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: "pollux/lib/target/test-reports/**/TEST-*.xml" - comment_title: "Pollux Test Results" - check_name: "Pollux Test Results" + uses: ./.github/workflows/scala-unit-tests.yml + with: + component-name: "Pollux Lib" + component-dir: "pollux/lib" + secrets: inherit + release: + if: github.event_name == 'push' + uses: ./.github/workflows/release.yml + with: + release-component: "pollux/lib" + secrets: inherit diff --git a/.github/workflows/prism-agent.yml b/.github/workflows/prism-agent.yml index 0a7ccc3f55..76005478d8 100644 --- a/.github/workflows/prism-agent.yml +++ b/.github/workflows/prism-agent.yml @@ -6,65 +6,30 @@ concurrency: group: ${{ github.head_ref }}${{ github.ref }}-prism-agent cancel-in-progress: true -# Default shell is `sh` -# which is old, use bourne-again version instead -defaults: - run: - shell: bash - working-directory: prism-agent/service - on: - # Run with every push to `main` branch - # Run with each PR opened vs PRISM agent push: branches: - - main + - "main" paths: - ".github/workflows/prism-agent.yml" + - ".github/workflows/scala-unit-tests.yml" - "prism-agent/**" pull_request: paths: - ".github/workflows/prism-agent.yml" + - ".github/workflows/scala-unit-tests.yml" - "prism-agent/**" -# Global environment variables for all jobs -env: - GITHUB_TOKEN: ${{ secrets.ATALA_GITHUB_TOKEN }} - ATALA_GITHUB_TOKEN: ${{ secrets.ATALA_GITHUB_TOKEN }} - jobs: build-and-test-prism-agent: - name: "Build and test prism agent" - 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 Castor - run: sbt test - - - name: Aggregate test reports - if: always() - uses: ./.github/actions/aggregate-test-reports - with: - tests-dir: "prism-agent/service" - - - 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: "prism-agent/service/target/test-reports/**/TEST-*.xml" - comment_title: "PRISM Agent Test Results" - check_name: "PRISM Agent Test Results" + uses: ./.github/workflows/scala-unit-tests.yml + with: + component-name: "PRISM Agent" + component-dir: "prism-agent/service" + secrets: inherit + release: + if: github.event_name == 'push' + uses: ./.github/workflows/release.yml + with: + release-component: "prism-agent/service" + secrets: inherit diff --git a/.github/workflows/prism-node-client.yml b/.github/workflows/prism-node-client.yml index fb3c86a633..1c732d3993 100644 --- a/.github/workflows/prism-node-client.yml +++ b/.github/workflows/prism-node-client.yml @@ -7,45 +7,29 @@ concurrency: cancel-in-progress: true on: - pull_request: - paths: - - ".github/workflows/prism-node-client.yml" - - "prism-node/client/**" push: branches: - "main" paths: - ".github/workflows/prism-node-client.yml" + - ".github/workflows/scala-unit-tests.yml" + - "prism-node/client/**" + pull_request: + paths: + - ".github/workflows/prism-node-client.yml" + - ".github/workflows/scala-unit-tests.yml" - "prism-node/client/**" - -env: - GITHUB_TOKEN: ${{ secrets.ATALA_GITHUB_TOKEN }} - ATALA_GITHUB_TOKEN: ${{ secrets.ATALA_GITHUB_TOKEN }} - -defaults: - run: - shell: bash - working-directory: "prism-node/client/scala-client" jobs: build-and-test-prism-node-client: - name: "Build and test Prism node client" - 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 Prism node client - run: sbt compile + uses: ./.github/workflows/scala-unit-tests.yml + with: + component-name: "PRISM Node Client" + component-dir: "prism-node/client/scala-client" + secrets: inherit + release: + if: github.event_name == 'push' + uses: ./.github/workflows/release.yml + with: + release-component: "prism-node/client/scala-client" + secrets: inherit diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 16b1d9b785..fedcd243c8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,6 +4,15 @@ concurrency: group: release on: + workflow_call: + inputs: + release-component: + required: true + type: string + release-branch: + required: false + type: string + default: "main" workflow_dispatch: inputs: release-component: @@ -23,7 +32,6 @@ jobs: ATALA_GITHUB_TOKEN: ${{ secrets.ATALA_GITHUB_TOKEN }} SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} SBT_PACKAGER: "enable" # To enable the packager plugin on Mercury - runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -58,6 +66,6 @@ jobs: GIT_AUTHOR_NAME: ${{ steps.import_gpg.outputs.name }} GIT_COMMITTER_NAME: ${{ steps.import_gpg.outputs.name }} run: | - cd ${{ github.event.inputs.release-component }} + cd ${{ inputs.release-component }} npm install npx semantic-release -e semantic-release-monorepo diff --git a/.github/workflows/scala-steward.yml b/.github/workflows/scala-steward.yml index 5b590fc9a8..0f040df6bf 100644 --- a/.github/workflows/scala-steward.yml +++ b/.github/workflows/scala-steward.yml @@ -25,6 +25,7 @@ jobs: uses: scala-steward-org/scala-steward-action@v2 env: GITHUB_TOKEN: ${{ secrets.ATALA_GITHUB_TOKEN }} + ATALA_GITHUB_TOKEN: ${{ secrets.ATALA_GITHUB_TOKEN }} with: github-token: ${{ secrets.ATALA_GITHUB_TOKEN }} sign-commits: true diff --git a/.github/workflows/scala-unit-tests.yml b/.github/workflows/scala-unit-tests.yml new file mode 100644 index 0000000000..57ba61bcaa --- /dev/null +++ b/.github/workflows/scala-unit-tests.yml @@ -0,0 +1,77 @@ +name: Scala build and unit tests + +on: + workflow_call: + inputs: + component-name: + required: true + type: string + component-dir: + required: true + type: string + +jobs: + build-and-unit-tests: + name: "Build and unit tests for ${{ inputs.component-name }}" + runs-on: ubuntu-latest + env: + GITHUB_TOKEN: ${{ secrets.ATALA_GITHUB_TOKEN }} + ATALA_GITHUB_TOKEN: ${{ secrets.ATALA_GITHUB_TOKEN }} + SBT_PACKAGER: "enable" + SBT_SCOVERAGE: "enable" + defaults: + run: + working-directory: ${{ inputs.component-dir }} + 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: Run Unit Tests + run: | + if [[ ${{ inputs.component-dir }} == mercury/mercury-library ]]; then + SBT_SCOVERAGE=enable sbt clean coverage test coverageAggregate + else + sbt test + fi + + - name: Aggregate test reports + if: always() + uses: ./.github/actions/aggregate-test-reports + with: + tests-dir: ${{ inputs.component-dir }} + + - 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: "${{ inputs.component-dir }}/target/test-reports/**/TEST-*.xml" + comment_title: "${{ inputs.component-name }} Test Results" + check_name: "${{ inputs.component-name }} Test Results" + + - name: Code coverage report + if: inputs.component-dir == 'mercury/mercury-library' + uses: 5monkeys/cobertura-action@master + with: + path: "${{ inputs.component-dir }}/target/coverage/coverage-report/cobertura.xml" + report_name: "{{ inputs.component-name }} Code Coverage" + minimum_coverage: 10 + fail_below_threshold: false + + - name: Artifact coverage HTML + uses: actions/upload-artifact@v2 + if: inputs.component-dir == 'mercury/mercury-library' + with: + name: code-coverage-report-mercury + path: "${{ inputs.component-dir }}/target/coverage/scoverage-report"