Skip to content

Commit

Permalink
Coalesce build steps in build.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
ascopes authored Sep 29, 2024
1 parent f951e1a commit 0285706
Showing 1 changed file with 22 additions and 54 deletions.
76 changes: 22 additions & 54 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,14 @@ name: Build

on:
pull_request:
branches:
- main
branches: [main]
push:
branches:
- main
workflow_call: {}
branches: [main]
workflow_dispatch: {}

jobs:
build-x86_64-crossos:
name: jdk-${{ matrix.java-version }}/${{ matrix.os-name }}/x86_64
build:
name: ${{ matrix.java-version }}/${{ matrix.os-name }}/${{ matrix.maven}}-maven
runs-on: ${{ matrix.os-name }}
timeout-minutes: 30

Expand All @@ -21,25 +18,33 @@ jobs:
matrix:
os-name: [ubuntu-latest, macos-latest, windows-latest]
java-version: [11, 23]
maven: [default, prerequisite]

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up JDK ${{ matrix.java-version }}
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java-version }}
distribution: 'temurin'
cache: maven

- name: Change Maven version to the prerequisite version
if: ${{ matrix.maven == "prerequisite" }}
shell: bash
run: |-
version=$(./mvnw -B -T1 -q -pl protobuf-maven-plugin help:evaluate -DforceStdout -Dexpression='project.prerequisites.maven')
./mvnw -B -T1 -q wrapper:wrapper "-Dmaven=${version}"
- name: Install protoc to $PATH
shell: bash
run: scripts/install-protoc-to-github-runner.sh

- name: Build and test
shell: bash
run: ./mvnw -B verify
run: ./mvnw -B -Dcheckstyle.skip -Dlicense.skip verify

- name: Publish code coverage
uses: codecov/codecov-action@v4
Expand All @@ -52,7 +57,7 @@ jobs:
uses: actions/upload-artifact@v4
if: always()
with:
name: jdk-${{ matrix.java-version }}-${{ matrix.os-name }}-logs
name: jdk-${{ matrix.java-version }}-${{ matrix.os-name }}-${{ matrix.maven }}
path: |-
**/build.log
**/maven-status/**
Expand All @@ -62,61 +67,24 @@ jobs:
include-hidden-files: true
if-no-files-found: warn

build-x86_64-old-maven:
name: jdk-${{ matrix.java-version }}/ubuntu-latest/x86_64 (oldest supported Maven)
validate:
name: Validate build
runs-on: ubuntu-latest
timeout-minutes: 30

strategy:
fail-fast: false
matrix:
java-version: [11, 23]

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up JDK ${{ matrix.java-version }}
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java-version }}
java-version: 23
distribution: 'temurin'
cache: maven

- name: Change Maven version to the prerequisite version
- name: Validate
shell: bash
run: |-
version=$(./mvnw -B -T1 -q -pl protobuf-maven-plugin help:evaluate -DforceStdout -Dexpression='project.prerequisites.maven')
./mvnw -B -T1 -q wrapper:wrapper "-Dmaven=${version}"
- name: Install protoc to $PATH
shell: bash
run: scripts/install-protoc-to-github-runner.sh

- name: Build and test
shell: bash
run: ./mvnw -B verify

- name: Publish code coverage
uses: codecov/codecov-action@v4
continue-on-error: true
if: always()
with:
token: ${{ secrets.CODECOV_TOKEN }}

- name: Upload build logs as artifacts
uses: actions/upload-artifact@v4
if: always()
with:
name: jdk-${{ matrix.java-version }}-old-maven-logs
path: |-
**/build.log
**/maven-status/**
**/surefire-reports/**.txt
compression-level: 9
retention-days: 7
include-hidden-files: true
if-no-files-found: warn
run: ./mvnw -B validate

build-pages:
name: Generate pages
Expand All @@ -126,7 +94,7 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up JDK 23
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: 23
Expand Down

0 comments on commit 0285706

Please sign in to comment.