Skip to content

Add GitHub Actions workflow for Catroid release pipeline #49

Add GitHub Actions workflow for Catroid release pipeline

Add GitHub Actions workflow for Catroid release pipeline #49

Workflow file for this run

name: Catroid Pipeline
on:
push:
branches:
- "**"
pull_request:
branches:
- "**"
# schedule:
# - cron: "0 0 * * *" # Run daily at midnight
workflow_dispatch:
inputs:
WEB_TEST_URL:
description: "When set, all the archived APKs will point to this Catrobat web server, useful for testing web changes. E.g https://web-test.catrob.at"
required: false
type: string
default: ""
BUILD_ALL_FLAVOURS:
description: "When selected all flavours are built and archived as artifacts that can be installed alongside other versions of the same APKs"
required: false
type: boolean
default: false
jobs:
build:
name: Build APK
runs-on: ubuntu-latest
env:
WEB_TEST_URL: ${{ inputs.WEB_TEST_URL != '' && format('-PwebTestUrl=''{0}''', inputs.WEB_TEST_URL) || '' }}
ALL_FLAVOURS_PARAMETERS: ${{ inputs.BUILD_ALL_FLAVOURS && 'assembleCreateAtSchoolDebug assembleLunaAndCatDebug assemblePhiroDebug assembleEmbroideryDesignerDebug assemblePocketCodeBetaDebug assembleMindstormsDebug' || '' }}
steps:
- uses: actions/checkout@v4
- name: Setup JDK 21
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: 21
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Build APK
run: ./gradlew ${{ env.WEB_TEST_URL }} -Pindependent='#${{ github.run_number }} ${{ github.ref_name }}' assembleCatroidDebug ${{ env.ALL_FLAVOURS_PARAMETERS }}
# TODO: Check where to upload the APKs as GitHub Storage is an issue
#
# - name: Rename APKs
# run: |
# for file in $(find . -name "*.apk"); do
# mv "$file" "$(dirname "$file")/${{ github.ref_name }}-${{ github.run_number }}-$(basename "$file")"
# done
#
# - name: Archive APKs
# uses: actions/upload-artifact@v4
# with:
# name: apk-artifacts
# path: "**/*.apk"
unit-tests:
name: Unit Tests
runs-on: ubuntu-latest
env:
WEB_TEST_URL: ${{ inputs.WEB_TEST_URL != '' && format('-PwebTestUrl=''{0}''', inputs.WEB_TEST_URL) || '' }}
ALL_FLAVOURS_PARAMETERS: ${{ inputs.BUILD_ALL_FLAVOURS && 'assembleCreateAtSchoolDebug assembleLunaAndCatDebug assemblePhiroDebug assembleEmbroideryDesignerDebug assemblePocketCodeBetaDebug assembleMindstormsDebug' || '' }}
steps:
- uses: actions/checkout@v4
- name: Setup JDK 21
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: 21
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Run Unit Tests
run: ./gradlew -PenableCoverage jacocoTestCatroidDebugUnitTestReport --full-stacktrace
- name: Test Report
uses: dorny/test-reporter@v1
if: success() || failure()
with:
name: Unit Tests
path: catroid/build/test-results/**/*TEST*.xml
reporter: java-junit
- name: Upload Unit Test Reports
uses: actions/upload-artifact@v4
if: success() || failure()
with:
name: unit-test-report
path: |
catroid/build/reports/tests/testCatroidDebugUnitTest
code-analysis:
name: Code Analysis
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
tool:
- { name: "pmd", sarif: false }
- { name: "checkstyle", sarif: true }
- { name: "detekt", sarif: true }
- { name: "lint", sarif: true }
steps:
- uses: actions/checkout@v4
- name: Setup JDK 21
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: 21
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Run ${{ matrix.tool.name }} Analysis
run: |
case ${{ matrix.tool.name }} in
"pmd") ./gradlew pmd ;;
"checkstyle") ./gradlew checkstyle ;;
"detekt") ./gradlew detekt ;;
"lint") ./gradlew lintCatroidDebug ;;
esac
- name: Upload ${{ matrix.tool.name }} SARIF Report
uses: github/codeql-action/upload-sarif@v3
if: ${{ matrix.tool.sarif && (success() || failure()) }}
with:
sarif_file: catroid/build/reports/${{ matrix.tool.name }}.sarif
category: ${{ matrix.tool.name }}
- name: Upload ${{ matrix.tool.name }} HTML Report
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.tool.name }}-report
path: |
catroid/build/reports/html/${{ matrix.tool.name }}.html