From 6e067af09f98459ce4d93b2d2eb81f451035d699 Mon Sep 17 00:00:00 2001 From: sebastianMindee Date: Wed, 22 Jan 2025 14:34:58 +0100 Subject: [PATCH] :recycle: harmonize CI --- .../{publish.yml => _publish-code.yml} | 4 ++-- .../workflows/{docs.yml => _publish-docs.yml} | 12 +++++----- .../{sync-readme.yml => _publish-guide.yml} | 7 ++---- .../{linting.yml => _static-analysis.yml} | 2 +- ...ode-samples.yml => _test-code-samples.yml} | 6 +---- ...ration-test.yml => _test-integrations.yml} | 23 ++++++++++++++---- .../workflows/{test.yml => _test-units.yml} | 7 +++--- .github/workflows/cron.yml | 10 ++++++++ .github/workflows/publish-release.yml | 17 +++++++++++++ .github/workflows/pull-request.yml | 24 +++++++++++++++++++ .github/workflows/push-main-branch.yml | 17 +++++++++++++ 11 files changed, 102 insertions(+), 27 deletions(-) rename .github/workflows/{publish.yml => _publish-code.yml} (94%) rename .github/workflows/{docs.yml => _publish-docs.yml} (73%) rename .github/workflows/{sync-readme.yml => _publish-guide.yml} (72%) rename .github/workflows/{linting.yml => _static-analysis.yml} (96%) rename .github/workflows/{test-code-samples.yml => _test-code-samples.yml} (86%) rename .github/workflows/{integration-test.yml => _test-integrations.yml} (68%) rename .github/workflows/{test.yml => _test-units.yml} (92%) create mode 100644 .github/workflows/cron.yml create mode 100644 .github/workflows/publish-release.yml create mode 100644 .github/workflows/pull-request.yml create mode 100644 .github/workflows/push-main-branch.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/_publish-code.yml similarity index 94% rename from .github/workflows/publish.yml rename to .github/workflows/_publish-code.yml index a3271435..c67558c7 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/_publish-code.yml @@ -1,8 +1,8 @@ name: Publish on: - release: - types: [ published ] + workflow_call: + workflow_dispatch: jobs: linting: diff --git a/.github/workflows/docs.yml b/.github/workflows/_publish-docs.yml similarity index 73% rename from .github/workflows/docs.yml rename to .github/workflows/_publish-docs.yml index 687d6229..940256f8 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/_publish-docs.yml @@ -1,10 +1,10 @@ +# +# Publish Documentation to GitHub pages. +# name: Publish Documentation on: - release: - types: [ published ] - - # Allows running this workflow manually from the Actions tab + workflow_call: workflow_dispatch: jobs: @@ -17,7 +17,7 @@ jobs: - name: set up Ruby uses: ruby/setup-ruby@v1 with: - ruby-version: "3.1" + ruby-version: "3.3" bundler-cache: true - name: Analyse the code with Rubocop @@ -25,7 +25,7 @@ jobs: bundle exec rake doc - name: Deploy - uses: peaceiris/actions-gh-pages@v3 + uses: peaceiris/actions-gh-pages@v4 with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: ./docs/_build diff --git a/.github/workflows/sync-readme.yml b/.github/workflows/_publish-guide.yml similarity index 72% rename from .github/workflows/sync-readme.yml rename to .github/workflows/_publish-guide.yml index c3814875..c6ed9276 100644 --- a/.github/workflows/sync-readme.yml +++ b/.github/workflows/_publish-guide.yml @@ -1,11 +1,8 @@ -name: Sync `documentation` directory to ReadMe +name: Publish Guide to readme.com -# Run workflow for every push to the `main` branch on: + workflow_call: workflow_dispatch: - release: - branches: - - main jobs: sync: diff --git a/.github/workflows/linting.yml b/.github/workflows/_static-analysis.yml similarity index 96% rename from .github/workflows/linting.yml rename to .github/workflows/_static-analysis.yml index 241e321e..27963d31 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/_static-analysis.yml @@ -4,7 +4,7 @@ name: Static Analysis on: - - push + workflow_call: jobs: linting: diff --git a/.github/workflows/test-code-samples.yml b/.github/workflows/_test-code-samples.yml similarity index 86% rename from .github/workflows/test-code-samples.yml rename to .github/workflows/_test-code-samples.yml index b64187bf..b46ea2e4 100644 --- a/.github/workflows/test-code-samples.yml +++ b/.github/workflows/_test-code-samples.yml @@ -1,11 +1,7 @@ name: Test Code Samples on: - pull_request: - schedule: - - cron: '0 0 * * *' - - # Allow running this workflow manually from the Actions tab + workflow_call: workflow_dispatch: jobs: diff --git a/.github/workflows/integration-test.yml b/.github/workflows/_test-integrations.yml similarity index 68% rename from .github/workflows/integration-test.yml rename to .github/workflows/_test-integrations.yml index 37bbd1a4..d46d4f9e 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/_test-integrations.yml @@ -1,19 +1,22 @@ # -# Run Integration tests. +# Run integration tests. # name: Integration Tests on: - - push + workflow_call: jobs: - tests: - name: Test ${{ matrix.os }}, Ruby ${{ matrix.ruby }} + integration-tests: + name: Run Integration Tests + timeout-minutes: 30 runs-on: ${{ matrix.os }} strategy: + max-parallel: 3 matrix: os: - - "ubuntu-22.04" + - "ubuntu-24.04" + - "macos-latest" ruby: - "3.0" - "3.1" @@ -53,3 +56,13 @@ jobs: WORKFLOW_ID: ${{ secrets.WORKFLOW_ID_SE_TESTS }} run: | bundle exec rake integration + + - name: Notify Slack Action on Failure + uses: ravsamhq/notify-slack-action@2.3.0 + if: ${{ always() && github.ref_name == 'main' }} + with: + status: ${{ job.status }} + notify_when: "failure" + notification_title: "[Ruby] Integration test '{workflow}' is failing" + env: + SLACK_WEBHOOK_URL: ${{ secrets.PRODUCTION_ISSUES_SLACK_HOOK_URL }} diff --git a/.github/workflows/test.yml b/.github/workflows/_test-units.yml similarity index 92% rename from .github/workflows/test.yml rename to .github/workflows/_test-units.yml index b7eff786..75a0b494 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/_test-units.yml @@ -4,17 +4,18 @@ name: Tests on: - - push + workflow_call: jobs: tests: - name: Test ${{ matrix.os }}, Ruby ${{ matrix.ruby }} + name: Run Unit Tests + timeout-minutes: 30 runs-on: ${{ matrix.os }} strategy: matrix: os: + - "ubuntu-24.04" - "ubuntu-22.04" - - "ubuntu-20.04" - "macos-latest" ruby: - "3.0" diff --git a/.github/workflows/cron.yml b/.github/workflows/cron.yml new file mode 100644 index 00000000..e7f14660 --- /dev/null +++ b/.github/workflows/cron.yml @@ -0,0 +1,10 @@ +name: Crontab + +on: + schedule: + - cron: '0 0 * * *' + +jobs: + test_code_samples: + uses: mindee/mindee-api-ruby/.github/workflows/_test-code-samples.yml@main + secrets: inherit diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml new file mode 100644 index 00000000..a1178aeb --- /dev/null +++ b/.github/workflows/publish-release.yml @@ -0,0 +1,17 @@ +name: Publish Release + +on: + release: + types: [ published ] + +jobs: + publish_docs: + uses: mindee/mindee-api-ruby/.github/workflows/_publish-docs.yml@main + secrets: inherit + publish_guide: + uses: mindee/mindee-api-ruby/.github/workflows/_publish-guide.yml@main + needs: publish_docs + secrets: inherit + publish_code: + uses: mindee/mindee-api-ruby/.github/workflows/_publish-code.yml@main + secrets: inherit diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml new file mode 100644 index 00000000..eb5822a7 --- /dev/null +++ b/.github/workflows/pull-request.yml @@ -0,0 +1,24 @@ +name: Pull Request + +on: + pull_request: + +jobs: + static_analysis: + uses: mindee/mindee-api-ruby/.github/workflows/_static-analysis.yml@main + test_units: + uses: mindee/mindee-api-ruby/.github/workflows/_test-units.yml@main + needs: static_analysis + secrets: inherit + test_regressions: + uses: mindee/mindee-api-ruby/.github/workflows/_test-regressions.yml@main + needs: test_units + secrets: inherit + test_integrations: + uses: mindee/mindee-api-ruby/.github/workflows/_test-integrations.yml@main + needs: test_units + secrets: inherit + test_code_samples: + uses: mindee/mindee-api-ruby/.github/workflows/_test-code-samples.yml@main + needs: test_units + secrets: inherit diff --git a/.github/workflows/push-main-branch.yml b/.github/workflows/push-main-branch.yml new file mode 100644 index 00000000..f2cf102d --- /dev/null +++ b/.github/workflows/push-main-branch.yml @@ -0,0 +1,17 @@ +name: Push Main Branch + +on: + push: + branches: + - main + +jobs: + static_analysis: + uses: mindee/mindee-api-ruby/.github/workflows/_static-analysis.yml@main + test_units: + uses: mindee/mindee-api-ruby/.github/workflows/_test-units.yml@main + needs: static_analysis + secrets: inherit + tag: + uses: mindee/client-lib-actions/.github/workflows/tag-version.yml@main + needs: test_units