Maven Tests workflow (google/differential-privacy)
The Maven Tests workflow from google/differential-privacy, explained and optimized by Latchkey.
CI health: C - fair
Point runs-on at Latchkey and get caching, run de-duplication, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the Maven Tests workflow from the google/differential-privacy repository, a real project running GitHub Actions. It is shown here with attribution under its Apache-2.0 license.
Below, Latchkey shows a faster, safer version produced by its optimization engine.
The workflow
name: Maven Tests
on: [push, pull_request, workflow_dispatch]
jobs:
pipelinedp4j-tests:
name: PipelineDP4J Maven Tests
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@v6
- name: Cache Maven dependencies
uses: actions/cache@v5
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('examples/pipelinedp4j/pom.xml', 'examples/pipelinedp4j/**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Set up JDK 11
uses: actions/setup-java@v5
with:
java-version: '11'
distribution: 'temurin'
- name: Install Maven
run: sudo apt-get install -y maven
- name: Create dummy input file for examples
working-directory: examples/pipelinedp4j
run: |
cat << EOF > input.csv
4505,573364,5,2004-13-29
4501,2532865,4,2005-11-06
4501,573364,2,2005-02-25
4500,2532865,2,2004-12-12
4505,1265574,4,2003-05-05
4505,2532865,1,2004-12-12
EOF
- name: Install common package for examples
working-directory: examples/pipelinedp4j
run: mvn install
- name: Run Beam Example
working-directory: examples/pipelinedp4j/beam
run: mvn compile exec:java -Dexec.mainClass=com.google.privacy.differentialprivacy.pipelinedp4j.examples.BeamExample -Dexec.args="--inputFilePath=$(pwd)/../input.csv --outputFilePath=output.txt"
- name: Run Spark Example
working-directory: examples/pipelinedp4j/spark
run: mvn compile exec:java -Dexec.mainClass=com.google.privacy.differentialprivacy.pipelinedp4j.examples.SparkExample -Dexec.args="--inputFilePath=$(pwd)/../input.csv --outputFolder=output"
- name: Run Spark DataFrame Example
working-directory: examples/pipelinedp4j/spark
run: mvn compile exec:java -Dexec.mainClass=com.google.privacy.differentialprivacy.pipelinedp4j.examples.SparkDataFrameExample -Dexec.args="--inputFilePath=$(pwd)/../input.csv --outputFolder=output"
The same workflow, on Latchkey
Estimated ~20% faster on cache hits, plus fewer wasted runs and a safer supply chain. Added and changed lines are highlighted.
name: Maven Tests on: [push, pull_request, workflow_dispatch] concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: pipelinedp4j-tests: name: PipelineDP4J Maven Tests runs-on: latchkey-small timeout-minutes: 60 steps: - uses: actions/checkout@v6 - name: Cache Maven dependencies uses: actions/cache@v5 with: path: ~/.m2/repository key: ${{ runner.os }}-maven-${{ hashFiles('examples/pipelinedp4j/pom.xml', 'examples/pipelinedp4j/**/pom.xml') }} restore-keys: | ${{ runner.os }}-maven- - name: Set up JDK 11 uses: actions/setup-java@v5 with: cache: 'maven' java-version: '11' distribution: 'temurin' - name: Install Maven run: sudo apt-get install -y maven - name: Create dummy input file for examples working-directory: examples/pipelinedp4j run: | cat << EOF > input.csv 4505,573364,5,2004-13-29 4501,2532865,4,2005-11-06 4501,573364,2,2005-02-25 4500,2532865,2,2004-12-12 4505,1265574,4,2003-05-05 4505,2532865,1,2004-12-12 EOF - name: Install common package for examples working-directory: examples/pipelinedp4j run: mvn install - name: Run Beam Example working-directory: examples/pipelinedp4j/beam run: mvn compile exec:java -Dexec.mainClass=com.google.privacy.differentialprivacy.pipelinedp4j.examples.BeamExample -Dexec.args="--inputFilePath=$(pwd)/../input.csv --outputFilePath=output.txt" - name: Run Spark Example working-directory: examples/pipelinedp4j/spark run: mvn compile exec:java -Dexec.mainClass=com.google.privacy.differentialprivacy.pipelinedp4j.examples.SparkExample -Dexec.args="--inputFilePath=$(pwd)/../input.csv --outputFolder=output" - name: Run Spark DataFrame Example working-directory: examples/pipelinedp4j/spark run: mvn compile exec:java -Dexec.mainClass=com.google.privacy.differentialprivacy.pipelinedp4j.examples.SparkDataFrameExample -Dexec.args="--inputFilePath=$(pwd)/../input.csv --outputFolder=output"
What changed
- Run on Latchkey managed runners with one line (
runs-on), which apply the fixes below automatically and self-heal transient failures. This example useslatchkey-small; pick the runner size that fits the job. - Cancel superseded runs when a branch or PR gets a newer push.
- Cache dependency installs on the setup step so they are served from cache.
What Latchkey heals here
This workflow has steps that commonly fail on transient issues (network, registries, flaky browsers). On Latchkey managed runners they are detected, retried, and self-healed instead of failing your build:
- Dependency installs
This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.