From 827bcf4078edeac4986d3bd8facd90d370465141 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathieu=20M=C3=A9a?= Date: Wed, 5 Nov 2025 16:15:34 -0500 Subject: [PATCH 1/6] CI > build > reusable workflow --- .github/workflows/mt-build.yml | 109 +-------------------------------- 1 file changed, 1 insertion(+), 108 deletions(-) diff --git a/.github/workflows/mt-build.yml b/.github/workflows/mt-build.yml index 955d56d..680b74f 100644 --- a/.github/workflows/mt-build.yml +++ b/.github/workflows/mt-build.yml @@ -18,111 +18,4 @@ env: MT_SHA: ${{ github.event.pull_request.head.sha || github.sha }} jobs: MT-BUILD-JOB: - name: "MT Build" - runs-on: ubuntu-latest - steps: - - - name: MT select main repo checkout branch - id: mt-pick-main-repo-checkout-branch - env: - GH_TOKEN: ${{ github.token }} # GitHub CLI in a GitHub Actions workflow - run: | - REPOSITORY_OWNER_AND_NAME=${{ github.repository }}; - REPOSITORY_NAME=$(basename $REPOSITORY_OWNER_AND_NAME); - if [ $REPOSITORY_OWNER_AND_NAME = "mtransitapps/mtransit-for-android" ]; then - CHECKOUT_BRANCH="" # defaults to the reference or SHA for that event - else - MAIN_REPO_URL="https://github.com/mtransitapps/mtransit-for-android.git" - BRANCH_EXISTS=$(git ls-remote --heads $MAIN_REPO_URL $MT_BRANCH_NAME | wc -l); - if [ $BRANCH_EXISTS -eq 1 ]; then - CHECKOUT_BRANCH=$MT_BRANCH_NAME - else - # Pull request target branch with same name? - BRANCH_EXISTS=$(git ls-remote --heads $MAIN_REPO_URL $MT_TARGET_BRANCH_NAME | wc -l); - if [ $BRANCH_EXISTS -eq 1 ]; then - CHECKOUT_BRANCH=$MT_TARGET_BRANCH_NAME - else - echo "WARNING: no match for current or target branch!!!" - DEFAULT_REPO_BRANCH=$(gh api repos/mtransitapps/mtransit-for-android --jq '.default_branch'); - CHECKOUT_BRANCH=$DEFAULT_REPO_BRANCH - fi - fi - fi - echo "Checkout branch: '$CHECKOUT_BRANCH'." - echo "mt_checkout_branch=$CHECKOUT_BRANCH" >> "$GITHUB_OUTPUT" - - - name: MT check out main repo - uses: actions/checkout@v5 - with: - repository: mtransitapps/mtransit-for-android - ref: ${{ steps.mt-pick-main-repo-checkout-branch.outputs.mt_checkout_branch }} - submodules: true # required to set right token - fetch-depth: 0 # fetch all (not required util release build) - - name: MT check out submodules - run: ./checkout_submodules.sh - - name: MT check out all git submodule closest branch - if: github.event_name == 'pull_request' - run: | - echo "Checking out submodules closest branch, '$MT_BRANCH_NAME' or '$MT_TARGET_BRANCH_NAME':" - git submodule foreach 'git checkout $MT_BRANCH_NAME || git checkout $MT_TARGET_BRANCH_NAME' - echo "Showing submodules current branch:" - git submodule foreach 'git branch --show-current' - - - name: MT check out this module repo build SHA - if: github.repository != 'mtransitapps/mtransit-for-android' - run: | - REPOSITORY_OWNER_AND_NAME=${{ github.repository }}; - REPOSITORY_NAME=$(basename $REPOSITORY_OWNER_AND_NAME); - echo "Checking our this repo '$REPOSITORY_NAME' workflow sha '$MT_SHA':" - git -C $REPOSITORY_NAME checkout $MT_SHA; - - - name: MT setup MT_GIT_BRANCH env - if: github.repository == 'mtransitapps/mtransit-for-android' || github.event_name != 'pull_request' - run: | - # MT_GIT_BRANCH=${GITHUB_REF##*/}" - MT_GIT_BRANCH=${{ github.head_ref || github.ref_name }} - # echo "MT_GIT_BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV - echo "MT_GIT_BRANCH=$MT_GIT_BRANCH" >> $GITHUB_ENV - - - name: MT code setup - run: ./commons/code_setup.sh - - name: MT set up JDK 17 - uses: actions/setup-java@v5 - with: - distribution: 'zulu' - java-version: '17' - - name: Setup Gradle - uses: gradle/actions/setup-gradle@v5 - - - name: MT test - run: ./test.sh - - name: MT artifact > unit tests XML results - uses: actions/upload-artifact@v5 - if: ${{ always() }} # even if tests fails - with: - name: unit-test-xml-results - path: | - */build/test-results/**/*.xml - */build/test-results/*.xml - */build/reports/*.xml - - name: MT artifact > HTML reports - uses: actions/upload-artifact@v5 - if: ${{ always() }} # even if tests fails - with: - name: html-reports - path: | - */build/reports/ - !**/*.xml - - - name: MT assemble release (APK & ABB) - if: github.event_name != 'pull_request' - run: ./assemble_release.sh - env: - MT_ENCRYPT_KEY: ${{ secrets.MT_ENCRYPT_KEY }} - - name: MT artifact > app-android > APK & ABB - uses: actions/upload-artifact@v5 - with: - name: app-android-apk-bundle - path: | - app-android/build/outputs/apk - app-android/build/outputs/bundle + uses: mtransitapps/mtransit-for-android/.github/workflows/mt-build.yml@mm/re-use_main_repo_ci_build_workflow From 0dcfdfb73a4eb2586a8958cb78a22a36624b4651 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathieu=20M=C3=A9a?= Date: Wed, 5 Nov 2025 16:16:34 -0500 Subject: [PATCH 2/6] fix --- .github/workflows/mt-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/mt-build.yml b/.github/workflows/mt-build.yml index 680b74f..8fb02a4 100644 --- a/.github/workflows/mt-build.yml +++ b/.github/workflows/mt-build.yml @@ -17,5 +17,5 @@ env: MT_TARGET_BRANCH_NAME: ${{ github.base_ref || github.ref_name }} MT_SHA: ${{ github.event.pull_request.head.sha || github.sha }} jobs: - MT-BUILD-JOB: + MT-MAIN-BUILD-JOB: uses: mtransitapps/mtransit-for-android/.github/workflows/mt-build.yml@mm/re-use_main_repo_ci_build_workflow From 8a54bb4ab576f593188529e627bae503ab45e4e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathieu=20M=C3=A9a?= Date: Wed, 5 Nov 2025 16:17:24 -0500 Subject: [PATCH 3/6] fix --- .github/workflows/mt-build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/mt-build.yml b/.github/workflows/mt-build.yml index 8fb02a4..449332e 100644 --- a/.github/workflows/mt-build.yml +++ b/.github/workflows/mt-build.yml @@ -9,9 +9,9 @@ on: # TODO 'develop', 'main'? # gh workflow run mt-build.yml --ref # gh run list --workflow=mt-build.yml -concurrency: - group: ${{ github.workflow }}-${{ github.ref || github.head_ref }} - cancel-in-progress: true +# concurrency: +# group: ${{ github.workflow }}-${{ github.ref || github.head_ref }} +# cancel-in-progress: true env: MT_BRANCH_NAME: ${{ github.head_ref || github.ref_name }} MT_TARGET_BRANCH_NAME: ${{ github.base_ref || github.ref_name }} From f65f8caaa7f15081f02dc240b637bb371ebf2d36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathieu=20M=C3=A9a?= Date: Wed, 5 Nov 2025 20:15:58 -0500 Subject: [PATCH 4/6] remove more --- .github/workflows/mt-build.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/mt-build.yml b/.github/workflows/mt-build.yml index 449332e..36f50a3 100644 --- a/.github/workflows/mt-build.yml +++ b/.github/workflows/mt-build.yml @@ -9,13 +9,6 @@ on: # TODO 'develop', 'main'? # gh workflow run mt-build.yml --ref # gh run list --workflow=mt-build.yml -# concurrency: -# group: ${{ github.workflow }}-${{ github.ref || github.head_ref }} -# cancel-in-progress: true -env: - MT_BRANCH_NAME: ${{ github.head_ref || github.ref_name }} - MT_TARGET_BRANCH_NAME: ${{ github.base_ref || github.ref_name }} - MT_SHA: ${{ github.event.pull_request.head.sha || github.sha }} jobs: MT-MAIN-BUILD-JOB: uses: mtransitapps/mtransit-for-android/.github/workflows/mt-build.yml@mm/re-use_main_repo_ci_build_workflow From 8703dcb8d062bbb1a9249997c494817fd79ad574 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathieu=20M=C3=A9a?= Date: Wed, 5 Nov 2025 20:19:35 -0500 Subject: [PATCH 5/6] clean --- .github/workflows/mt-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/mt-build.yml b/.github/workflows/mt-build.yml index 36f50a3..faaa13b 100644 --- a/.github/workflows/mt-build.yml +++ b/.github/workflows/mt-build.yml @@ -10,5 +10,5 @@ on: # gh workflow run mt-build.yml --ref # gh run list --workflow=mt-build.yml jobs: - MT-MAIN-BUILD-JOB: + MT-MAIN-REPO-BUILD-JOB: uses: mtransitapps/mtransit-for-android/.github/workflows/mt-build.yml@mm/re-use_main_repo_ci_build_workflow From 9c4337482c26f84a29d6f0aa82a40a91d958ecb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathieu=20M=C3=A9a?= Date: Wed, 5 Nov 2025 20:28:01 -0500 Subject: [PATCH 6/6] master branch --- .github/workflows/mt-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/mt-build.yml b/.github/workflows/mt-build.yml index faaa13b..dfdba33 100644 --- a/.github/workflows/mt-build.yml +++ b/.github/workflows/mt-build.yml @@ -11,4 +11,4 @@ on: # gh run list --workflow=mt-build.yml jobs: MT-MAIN-REPO-BUILD-JOB: - uses: mtransitapps/mtransit-for-android/.github/workflows/mt-build.yml@mm/re-use_main_repo_ci_build_workflow + uses: mtransitapps/mtransit-for-android/.github/workflows/mt-build.yml@master