mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-02-05 05:12:51 -05:00
90 lines
2.5 KiB
YAML
90 lines
2.5 KiB
YAML
name: Android CI (PR)
|
|
|
|
on:
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
workflow_dispatch: # Allow manual triggering
|
|
|
|
|
|
concurrency:
|
|
group: build-pr-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
test_secrets:
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
TEST_SECRET: ${{ secrets.TEST_SECRET }}
|
|
steps:
|
|
- name: Test Secrets
|
|
run: |
|
|
echo "$TEST_SECRET"
|
|
|
|
build_and_detekt:
|
|
if: github.repository == 'meshtastic/Meshtastic-Android' && github.head_ref != 'scheduled-updates'
|
|
uses: ./.github/workflows/reusable-android-build.yml
|
|
secrets: inherit
|
|
|
|
androidTest:
|
|
# Assuming androidTest should also only run for the main repository
|
|
if: github.repository == 'meshtastic/Meshtastic-Android' && github.head_ref != 'scheduled-updates'
|
|
uses: ./.github/workflows/reusable-android-test.yml
|
|
with:
|
|
api_levels: '[35]' # Run only on API 35 for PRs
|
|
# upload_artifacts defaults to true, so no need to explicitly set
|
|
secrets:
|
|
GRADLE_ENCRYPTION_KEY: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
|
|
|
|
check-workflow-status:
|
|
name: Check Workflow Status
|
|
runs-on: ubuntu-latest
|
|
needs:
|
|
[
|
|
build_and_detekt,
|
|
androidTest
|
|
]
|
|
if: always()
|
|
steps:
|
|
- name: Check Workflow Status
|
|
run: |
|
|
exit_on_result() {
|
|
if [[ "$2" == "failure" || "$2" == "cancelled" ]]; then
|
|
echo "Job '$1' failed or was cancelled."
|
|
exit 1
|
|
fi
|
|
}
|
|
exit_on_result "build_and_detekt" "${{ needs.build_and_detekt.result }}"
|
|
exit_on_result "androidTest" "${{ needs.androidTest.result }}"
|
|
|
|
labeler:
|
|
permissions:
|
|
contents: read
|
|
pull-requests: write
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- id: label-the-PR
|
|
uses: actions/labeler@v5
|
|
continue-on-error: true
|
|
|
|
check-label:
|
|
runs-on: ubuntu-latest
|
|
needs:
|
|
[
|
|
check-workflow-status,
|
|
labeler
|
|
]
|
|
if: always()
|
|
steps:
|
|
- name: Check for PR labels
|
|
uses: actions/github-script@v7
|
|
with:
|
|
script: |
|
|
const labels = context.payload.pull_request.labels.map(label => label.name);
|
|
const requiredLabels = ['bugfix', 'enhancement', 'automation', 'dependencies', 'repo', 'release'];
|
|
const hasRequiredLabel = labels.some(label => requiredLabels.includes(label));
|
|
console.log(labels);
|
|
if (!hasRequiredLabel) {
|
|
core.setFailed(`PR must have at least one of the following labels before it can be merged: ${requiredLabels.join(', ')}.`);
|
|
}
|