From 05e9bcc42729894903fbb5c054af46f764a6a752 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ianar=C3=A9=20S=C3=A9vi?= Date: Fri, 27 Dec 2024 18:24:25 +0100 Subject: [PATCH] :recycle: rework github actions for world peace --- .github/workflows/{build.yml => _build.yml} | 2 +- .../{checkstyle.yml => _checkstyle.yml} | 2 +- .github/workflows/{codeql.yml => _codeql.yml} | 11 ++--- .github/workflows/{docs.yml => _docs.yml} | 5 +- ...ation-tests.yml => _integration-tests.yml} | 5 +- .../{maven-publish.yml => _maven-publish.yml} | 7 +-- .../workflows/{sync-md.yml => _sync-md.yml} | 7 +-- ...ode-samples.yml => _test-code-samples.yml} | 8 +--- .github/workflows/cron.yml | 12 +++++ .github/workflows/publish-release.yml | 13 ++++++ .github/workflows/pull-request.yml | 23 ++++++++++ .github/workflows/push-main-branch.yml | 24 ++++++++++ .github/workflows/tag-version.yml | 46 ------------------- 13 files changed, 86 insertions(+), 79 deletions(-) rename .github/workflows/{build.yml => _build.yml} (98%) rename .github/workflows/{checkstyle.yml => _checkstyle.yml} (96%) rename .github/workflows/{codeql.yml => _codeql.yml} (92%) rename .github/workflows/{docs.yml => _docs.yml} (93%) rename .github/workflows/{integration-tests.yml => _integration-tests.yml} (94%) rename .github/workflows/{maven-publish.yml => _maven-publish.yml} (87%) rename .github/workflows/{sync-md.yml => _sync-md.yml} (72%) rename .github/workflows/{test-code-samples.yml => _test-code-samples.yml} (85%) 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 delete mode 100644 .github/workflows/tag-version.yml diff --git a/.github/workflows/build.yml b/.github/workflows/_build.yml similarity index 98% rename from .github/workflows/build.yml rename to .github/workflows/_build.yml index a658d7285..c94ea2fae 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/_build.yml @@ -1,7 +1,7 @@ name: Tests on: - - push + workflow_call: jobs: build: diff --git a/.github/workflows/checkstyle.yml b/.github/workflows/_checkstyle.yml similarity index 96% rename from .github/workflows/checkstyle.yml rename to .github/workflows/_checkstyle.yml index 0820490b3..1942a07c0 100644 --- a/.github/workflows/checkstyle.yml +++ b/.github/workflows/_checkstyle.yml @@ -1,7 +1,7 @@ name: Check Style on: - - push + workflow_call: jobs: check-style: diff --git a/.github/workflows/codeql.yml b/.github/workflows/_codeql.yml similarity index 92% rename from .github/workflows/codeql.yml rename to .github/workflows/_codeql.yml index 8eb3f42b6..25fe9b03d 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/_codeql.yml @@ -12,13 +12,8 @@ name: "CodeQL" on: - push: - branches: [ "main" ] - pull_request: - # The branches below must be a subset of the branches above - branches: [ "main" ] - schedule: - - cron: '33 17 * * 1' + workflow_call: + workflow_dispatch: jobs: analyze: @@ -69,6 +64,6 @@ jobs: # ./location_of_script_within_repo/buildscript.sh - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@v3 with: category: "/language:${{matrix.language}}" diff --git a/.github/workflows/docs.yml b/.github/workflows/_docs.yml similarity index 93% rename from .github/workflows/docs.yml rename to .github/workflows/_docs.yml index d14106f47..8d0631ac4 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/_docs.yml @@ -1,10 +1,7 @@ name: Publish Documentation on: - release: - types: [ published ] - - # Allows running this workflow manually from the Actions tab + workflow_call: workflow_dispatch: jobs: diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/_integration-tests.yml similarity index 94% rename from .github/workflows/integration-tests.yml rename to .github/workflows/_integration-tests.yml index 5eb3fd97b..2e7d4215d 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/_integration-tests.yml @@ -1,10 +1,9 @@ name: Integration Tests on: - pull_request: - schedule: - - cron: '0 23 * * *' + workflow_call: workflow_dispatch: + jobs: integration_tests: name: Run Integration Tests diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/_maven-publish.yml similarity index 87% rename from .github/workflows/maven-publish.yml rename to .github/workflows/_maven-publish.yml index 2d4137ba6..930639544 100644 --- a/.github/workflows/maven-publish.yml +++ b/.github/workflows/_maven-publish.yml @@ -1,10 +1,7 @@ -name: Publish package to the Maven Central Repository +name: Publish to Maven Central on: - release: - types: [ published ] - - # Allows running this workflow manually from the Actions tab + workflow_call: workflow_dispatch: jobs: diff --git a/.github/workflows/sync-md.yml b/.github/workflows/_sync-md.yml similarity index 72% rename from .github/workflows/sync-md.yml rename to .github/workflows/_sync-md.yml index b6f2ee0b4..623464721 100644 --- a/.github/workflows/sync-md.yml +++ b/.github/workflows/_sync-md.yml @@ -1,10 +1,7 @@ -name: Sync `documentation` directory to ReadMe +name: Sync documentation to ReadMe -# Run workflow for every push to the `main` branch on: - release: - branches: - - main + workflow_call: workflow_dispatch: jobs: diff --git a/.github/workflows/test-code-samples.yml b/.github/workflows/_test-code-samples.yml similarity index 85% rename from .github/workflows/test-code-samples.yml rename to .github/workflows/_test-code-samples.yml index 1019cab72..714d2bbe1 100644 --- a/.github/workflows/test-code-samples.yml +++ b/.github/workflows/_test-code-samples.yml @@ -1,10 +1,6 @@ -name: Test Samples Java Classes +name: Test Code Samples on: - pull_request: - schedule: - - cron: '0 23 * * *' - - # Allows to run this workflow manually from the Actions tab + workflow_call: workflow_dispatch: jobs: diff --git a/.github/workflows/cron.yml b/.github/workflows/cron.yml new file mode 100644 index 000000000..00c1448c4 --- /dev/null +++ b/.github/workflows/cron.yml @@ -0,0 +1,12 @@ +name: Crontab + +on: + schedule: + - cron: '33 0 * * *' + +jobs: + codeql: + uses: mindee/mindee-api-java/.github/workflows/_codeql.yml@new-actions + test_code_samples: + uses: mindee/mindee-api-java/.github/workflows/_test-code-samples.yml@new-actions + secrets: inherit diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml new file mode 100644 index 000000000..7b499aa3d --- /dev/null +++ b/.github/workflows/publish-release.yml @@ -0,0 +1,13 @@ +name: Publish Release + +on: + release: + types: [ published ] + +jobs: + docs-publish: + uses: mindee/mindee-api-java/.github/workflows/_docs.yml@main + secrets: inherit + maven-publish: + uses: mindee/mindee-api-java/.github/workflows/_maven-publish.yml@main + secrets: inherit diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml new file mode 100644 index 000000000..707279c06 --- /dev/null +++ b/.github/workflows/pull-request.yml @@ -0,0 +1,23 @@ +name: Pull Request + +on: + pull_request: + +jobs: + checkstyle: + uses: mindee/mindee-api-java/.github/workflows/_checkstyle.yml@new-actions + build: + uses: mindee/mindee-api-java/.github/workflows/_build.yml@new-actions + needs: checkstyle + secrets: inherit + codeql: + uses: mindee/mindee-api-java/.github/workflows/_codeql.yml@new-actions + needs: build + integration_tests: + uses: mindee/mindee-api-java/.github/workflows/_integration-tests.yml@new-actions + needs: build + secrets: inherit + test_code_samples: + uses: mindee/mindee-api-java/.github/workflows/_test-code-samples.yml@new-actions + needs: build + secrets: inherit diff --git a/.github/workflows/push-main-branch.yml b/.github/workflows/push-main-branch.yml new file mode 100644 index 000000000..068dcdba1 --- /dev/null +++ b/.github/workflows/push-main-branch.yml @@ -0,0 +1,24 @@ +name: Push Main Branch + +on: + push: + branches: + - main + +jobs: + checkstyle: + uses: mindee/mindee-api-java/.github/workflows/_checkstyle.yml@main + build: + uses: mindee/mindee-api-java/.github/workflows/_build.yml@main + needs: checkstyle + secrets: inherit + codeql: + uses: mindee/mindee-api-java/.github/workflows/codeql.yml@main + needs: build + sync-readme: + uses: mindee/mindee-api-java/.github/workflows/_sync-md.yml@main + needs: codeql + secrets: inherit + tag: + uses: mindee/client-lib-actions/.github/workflows/tag-version.yml@main + needs: codeql diff --git a/.github/workflows/tag-version.yml b/.github/workflows/tag-version.yml deleted file mode 100644 index 5047743e1..000000000 --- a/.github/workflows/tag-version.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: Tag Version - -on: - push: - branches: - - main - -jobs: - tag-version: - runs-on: ubuntu-latest - if: "contains(github.event.head_commit.message, ':bookmark:')" - - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: '0' - - - name: Tag version - run: | - msg_start=':bookmark: Version ' - version_format='[0-9]{1,}\.[0-9]{1,}\.[0-9]{1,}' - version=$(git log -1 --skip=0 --pretty=%s | grep -oP "(?<=${msg_start})${version_format}") - - if [ -z "${version}" ]; then - echo 'Version not found, aborting.' - exit 1 - fi - - echo "Found version: ${version}"; - tag="v${version}"; - - echo "Would tag: ${tag}"; - existing_tag=$(git tag -l "${tag}"); - - if [ "${existing_tag}" ]; then - echo "Tag '${existing_tag}' already exists, aborting."; - exit 1; - fi - - git config user.name "Mindee"; - git config user.email "opensource@mindee.com" - - git tag -a "${tag}" -m"Version ${version}"; - git push origin "${tag}" - - echo "Tagged and pushed: ${tag}"