From daf7ef8d114bbdc6b32ef015959c41fb74ed1435 Mon Sep 17 00:00:00 2001 From: Richard Tibbles Date: Wed, 17 Jan 2024 16:18:00 -0800 Subject: [PATCH 1/2] Limit linting checks to the develop branch. --- .github/workflows/pre-commit.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index bfa4205c..4b2c66e0 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -1,6 +1,12 @@ name: Linting -on: [push, pull_request] +on: + push: + branches: + - develop + pull_request: + branches: + - develop jobs: pre_job: From 8a07cf7d8307008f83d53938a202a5cbd8e7f3a1 Mon Sep 17 00:00:00 2001 From: Richard Tibbles Date: Thu, 18 Jan 2024 09:36:29 -0800 Subject: [PATCH 2/2] Add action to build APK using latest Kolibri release. --- .github/workflows/build_apk.yml | 19 +++++++++--- .github/workflows/pr_build.yml | 53 +++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/pr_build.yml diff --git a/.github/workflows/build_apk.yml b/.github/workflows/build_apk.yml index 58dcc656..5bb67cff 100644 --- a/.github/workflows/build_apk.yml +++ b/.github/workflows/build_apk.yml @@ -20,11 +20,14 @@ on: workflow_call: inputs: tar-file-name: - required: true + required: false + type: string + tar-url: + required: false type: string ref: description: 'A ref for this workflow to check out its own repo' - required: true + required: false type: string signed: description: 'Should this be signed with the development key? (mutually exclusive with release)' @@ -76,11 +79,16 @@ jobs: apk-file-name: ${{ steps.get-apk-filename.outputs.apk-file-name }} version-code: ${{ steps.get-version-code.outputs.version-code}} steps: - - name: Validate inputs + - name: Validate release flag inputs if: ${{ (inputs.release == true || github.event.inputs.release == 'true') && (inputs.signed == true || github.event.inputs.signed == 'true') }} run: | echo "Cannot build a release and signed development APK at the same time." exit 1 + - name: Validate tar reference inputs + if: ${{ !github.event.inputs.tar-file-name && ( (inputs.tar-file-name && inputs.tar-url) || (!inputs.tar-file-name && !inputs.tar-url) ) }} + run: | + echo "Must specify only one reference for the tar file to build the APK with." + exit 1 - uses: actions/checkout@v4 if: ${{ !inputs.ref }} - uses: actions/checkout@v4 @@ -132,9 +140,12 @@ jobs: key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }} restore-keys: | ${{ runner.os }}-pip- - - name: Download the tarfile from URL + - name: Download the tarfile from URL for workflow_dispatch if: ${{ github.event.inputs.tar-url }} run: make get-tar tar=${{ github.event.inputs.tar-url }} + - name: Download the tarfile from URL for workflow_call + if: ${{ inputs.tar-url }} + run: make get-tar tar=${{ inputs.tar-url }} - name: Download the tarfile from artifacts if: ${{ inputs.tar-file-name }} uses: actions/download-artifact@v4 diff --git a/.github/workflows/pr_build.yml b/.github/workflows/pr_build.yml new file mode 100644 index 00000000..45772a60 --- /dev/null +++ b/.github/workflows/pr_build.yml @@ -0,0 +1,53 @@ +name: Build APK for PRs + +on: + pull_request: + branches: + - develop + +jobs: + pre_job: + name: Path match check + runs-on: ubuntu-latest + # Map a step output to a job output + outputs: + should_skip: ${{ steps.skip_check.outputs.should_skip }} + steps: + - id: skip_check + uses: fkirc/skip-duplicate-actions@master + with: + github_token: ${{ github.token }} + paths_ignore: '["**.po", "**.json"]' + latest_kolibri_release: + needs: pre_job + if: ${{ needs.pre_job.outputs.should_skip != 'true' }} + runs-on: ubuntu-latest + outputs: + tar-url: ${{ steps.get_latest_kolibri_release.outputs.result }} + steps: + - name: Get latest Kolibri release + id: get_latest_kolibri_release + uses: actions/github-script@v7 + with: + result-encoding: string + script: | + + const { data: releases } = await github.rest.repos.listReleases({ + owner: 'learningequality', + repo: 'kolibri', + per_page: 1, + page: 1, + }); + + const latestRelease = releases[0]; + const tarAsset = latestRelease.assets.find(asset => asset.name.endsWith('.tar.gz')); + const tarUrl = tarAsset.browser_download_url; + return tarUrl; + + build_apk: + name: Build Debug APK + needs: [pre_job, latest_kolibri_release] + if: ${{ needs.pre_job.outputs.should_skip != 'true' }} + uses: ./.github/workflows/build_apk.yml + with: + tar-url: ${{ needs.latest_kolibri_release.outputs.tar-url }}