Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Github actions to run non-redundantly and build an APK asset #187

Merged
merged 2 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions .github/workflows/build_apk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)'
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
53 changes: 53 additions & 0 deletions .github/workflows/pr_build.yml
Original file line number Diff line number Diff line change
@@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is neat

with:
tar-url: ${{ needs.latest_kolibri_release.outputs.tar-url }}
8 changes: 7 additions & 1 deletion .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
name: Linting

on: [push, pull_request]
on:
push:
branches:
- develop
pull_request:
branches:
- develop

jobs:
pre_job:
Expand Down