Skip to content

New matrix operations and helper APIs #85

New matrix operations and helper APIs

New matrix operations and helper APIs #85

Workflow file for this run

name: Test
on:
# Run on push, pull request, and manual trigger
push:
# Only run when the specific files are changed
paths:
- '**/*.java' # Java files
- '**/*.py' # Python files
# Unlike push, the workflow always runs on pull requests
pull_request:
# The workflow also can be triggered manually, and choose whether
# to run with or without debug mode
workflow_dispatch:
inputs:
debug:
description: 'Debug Mode'
required: false
type: boolean
# Environment variables definitions
env:
## For Java installation
java-dist: temurin
## For Python installation
arch: x64
## Other environments
debug: ${{ inputs.debug }}
deps: requirements.txt
jobs:
# ::---:: Maven Test ::---:: #
maven-test:
name: Maven Test / ${{ matrix.os }} / ${{ matrix.java-ver }}
runs-on: ${{ matrix.os }}-latest
env:
# Maven's debug flag (`-X`)
mvnDebugFlag: ${{ inputs.debug == true && '-X' || '' }}
strategy:
# Set to maximum number of processes to speed up jobs run
max-parallel: 6
matrix:
os: [Ubuntu, Windows, macOS]
java-ver: [11, 17, 20] # JDK 11, 17 & 20
steps:
# Checkout repository
- name: Checkout repository
uses: actions/checkout@v4
# Caching Maven deps
- name: Cache Maven dependencies
id: cache-maven
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-jdk-${{ matrix.java-ver }}-${{ env.java-dist }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-jdk-${{ matrix.java-ver }}-${{ env.java-dist }}-maven-${{ hashFiles('**/pom.xml') }}
${{ runner.os }}-jdk-${{ matrix.java-ver }}-${{ env.java-dist }}-maven-
# Setup Java
- name: Setup Java / ${{ matrix.os }} / ${{ matrix.java-ver }}
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java-ver }}
distribution: ${{ env.java-dist }}
cache: 'maven'
cache-dependency-path: '**/pom.xml'
# Build the project
- name: Build with Maven
run: mvn -B package -P include-src -P lint ${{ env.mvnDebugFlag }}
shell: bash
# Clean up
- name: Clean up the project
run: mvn clean ${{ env.mvnDebugFlag }}
shell: bash
# ::---:: Make Test ::---:: #
make-test:
name: Make Test / Ubuntu / ${{ matrix.py-ver }}
runs-on: ubuntu-latest
env:
MAKE: ${{ inputs.debug == true && 'make -d' || 'make' }}
strategy:
# Set to maximum number of processes to speed up jobs run
max-parallel: 6
matrix:
py-ver: [3.7, 3.x] # Python 3.7 & latest of version 3
steps:
# Checkout
- name: Checkout repository
uses: actions/checkout@v4
# Setup Python
- name: Setup Python / Ubuntu / ${{ matrix.py-ver }}
id: setup-py
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.py-ver }}
architecture: ${{ env.arch }}
cache: pip
cache-dependency-path: '**/${{ env.deps }}'
# Install deps
- name: Install Python dependencies
if: ${{ steps.setup-py.outputs.cache-hit != true }}
run: |
if [ $debug = 'true' ]; then
python -m pip install -r $(git ls-files **/$deps) --debug
else
python -m pip install -r $(git ls-files **/$deps)
fi
shell: bash
# Sadly, Make cannot tests the project thoroughly due to unavailability
# of necessary packages (e.g "org.junit"), so here it just tests
# the project on compiling, packaging, and generating docs.
# Compile
- name: Compile the project
run: |
[ -d target ] && make clean > /dev/null
$MAKE compile LINT=true VERBOSE=$debug
shell: bash
# Build
- name: Build with Make
run: $MAKE package INCLUDE_SRC=true VERBOSE=$debug
shell: bash
# Clean up
- name: Clean up the project
run: $MAKE clean VERBOSE=$debug
shell: bash