feat(test): added unit testing and added to cicd

This commit is contained in:
Anthonyy232 committed 2025-12-21 20:55:46 -08:00
1 parent c46006858f
commit 8a5db6b89e
34 files changed
+3808 -486

No files matched your search

+47 -5
View File
@@ -1,19 +1,22 @@
# ===================================================================
# Paperize CI/CD Pipeline
#
# Automates the building and release process for the Paperize Android application.
# Automates the testing, building and release process for the Paperize Android application.
#
# Workflow Architecture:
# 1. Build: Compiles and signs the release APK.
# 2. Release: Publishes the APK to a draft GitHub Release, but only for version tags.
# 1. Test: Runs unit tests to ensure code quality.
# 2. Build: Compiles and signs the release APK (depends on test passing).
# 3. Release: Publishes the APK to a draft GitHub Release, but only for version tags.
#
# Triggering Conditions:
# - On push to `master`:
# - Executes the `build` job.
# - Executes the `test` and `build` jobs.
# - Produces a versioned build artifact for testing and internal distribution.
# - On push of a tag (e.g., `v1.2.3`):
# - Executes both jobs: `build` and `release`.
# - Executes all jobs: `test`, `build` and `release`.
# - Creates a formal, versioned draft release on GitHub with the signed APK attached.
# - On pull requests to `master`:
# - Executes only the `test` job to validate changes before merge.
# ===================================================================
name: Paperize CI/CD Pipeline
@@ -21,17 +24,55 @@ on:
push:
branches: [ "master" ]
tags: [ 'v*' ]
pull_request:
branches: [ "master" ]
jobs:
# ===================================================================
# JOB: test
#
# Runs unit tests to ensure code quality before building.
# ===================================================================
test:
name: Run Unit Tests
runs-on: ubuntu-latest
steps:
- name: Checkout repository source code
uses: actions/checkout@v5
- name: Set up JDK 17
uses: actions/setup-java@v5
with:
java-version: '17'
distribution: 'temurin'
cache: gradle
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Run unit tests
run: ./gradlew test
- name: Upload test reports
uses: actions/upload-artifact@v4
if: always()
with:
name: test-reports
path: app/build/reports/tests/
retention-days: 7
# ===================================================================
# JOB: build
#
# Compiles, signs, and packages the release APK. This job produces a
# versioned artifact that is used for both internal testing and the final release.
# Only runs after tests pass.
# ===================================================================
build:
name: Build Signed APK
runs-on: ubuntu-latest
needs: test
if: github.event_name == 'push'
steps:
- name: Checkout repository source code
uses: actions/checkout@v6
@@ -115,3 +156,4 @@ jobs:
files: ./apk-artifact/paperize-v*.apk
draft: true
generate_release_notes: true