Skip to content

Test and build on-demand #12

Test and build on-demand

Test and build on-demand #12

name: Test and build on-demand
on:
workflow_dispatch:
inputs:
source-branch:
type: string
required: true
description: Branch to run test against
jobs:
make-matrix:
name: make input matrix
runs-on: ${{ vars.BUILD_CONTAINER_DISTRO_VERSION }}
outputs:
input-matrix: ${{ steps.set.outputs.input-matrix }}
java-version: ${{ steps.get-java-version.outputs.java-version }}
steps:
- uses: actions/checkout@v4 # brings versions.json into the workspace
with:
ref: ${{ github.ref }}
- id: set # create the matrix (compact JSON string)
shell: bash
env:
DEFAULT_JSON: ${{ vars.DEFAULT_SERVER_VERSIONS }}
TEST_SERVERS_FILE_PATH: ${{ vars.TEST_SERVERS_FILE_PATH }}
run: |
FILE=${TEST_SERVERS_FILE_PATH}
if [[ -s "$FILE" ]]; then
echo "Using $FILE from repository"
JSON=$(cat "$FILE")
else
echo "$FILE missing or empty – using DEFAULT_SERVER_VERSIONS"
JSON="$DEFAULT_JSON"
fi
MATRIX=$(echo "$JSON" | jq -c '
to_entries
| map({
server: .key,
version: .value.version,
type: .value.type,
})
')
echo input-matrix="$MATRIX" >> $GITHUB_OUTPUT
- name: Get java version
id: get-java-version
run: |
echo java-version="$(grep '<java.version>' pom.xml | sed -e 's/<[^>]*>//g' | awk '{$1=$1};1' | sed 's/^1\.8$/8/')" >> $GITHUB_OUTPUT
- name: debug - print input variables
run: |
echo ${{ steps.get-java-version.outputs.java-version }}
echo ${{ steps.set.outputs.input-matrix }}
build-and-test:
uses: ./.github/workflows/test-branch.yaml
needs: make-matrix
strategy:
matrix:
include: ${{ fromJson(needs.make-matrix.outputs.input-matrix) }}
crypto-type: [bouncycastle, gnu]
name: build-${{ matrix.server }}-${{ matrix.version }}
with:
java-version: ${{ needs.make-matrix.outputs.java-version }}
crypto-type: ${{ matrix.crypto-type }}
source-branch: ${{ inputs.source-branch }}
run-tests: true
server-tag: ${{ matrix.version }}
server-type: ${{ matrix.type }}
secrets: inherit