Skip to content

Commit 18f4346

Browse files
committedMay 27, 2023
apacheGH-356: Modularize Github workflows
Split the single workflow into two workflows: a build workflow that compiles and tests and that runs on PRs and that can be called from master-build, which additionally deploys snapshots. That way we never have to worry about a PR build inadvertently trying to deploy.
1 parent 8b21743 commit 18f4346

File tree

2 files changed

+91
-67
lines changed

2 files changed

+91
-67
lines changed
 

‎.github/workflows/build.yml

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
name: build
19+
20+
on:
21+
pull_request:
22+
branches:
23+
- master
24+
workflow_call:
25+
26+
jobs:
27+
compile:
28+
runs-on: ${{ matrix.os }}
29+
strategy:
30+
matrix:
31+
os: [ ubuntu-latest, windows-latest ]
32+
java: [ '8' ]
33+
steps:
34+
- uses: actions/checkout@v3
35+
36+
- name: Set up JDK ${{ matrix.java }}
37+
uses: actions/setup-java@v3
38+
with:
39+
distribution: temurin
40+
java-version: ${{ matrix.java }}
41+
42+
- uses: actions/cache@v3
43+
with:
44+
path: ~/.m2/repository
45+
key: ${{ matrix.os }}-maven-${{ hashFiles('**/pom.xml') }}
46+
restore-keys: |
47+
${{ matrix.os }}-maven-
48+
49+
- name: Build with maven
50+
run: mvn -B --errors --activate-profiles ci --no-transfer-progress package -DskipTests
51+
52+
test:
53+
needs: compile
54+
runs-on: ${{ matrix.os }}
55+
strategy:
56+
matrix:
57+
os: [ ubuntu-latest, windows-latest ]
58+
java: [ '8', '11', '17' ]
59+
steps:
60+
- uses: actions/checkout@v3
61+
62+
- name: Set up JDK ${{ matrix.java }}
63+
uses: actions/setup-java@v3
64+
with:
65+
distribution: temurin
66+
java-version: ${{ matrix.java }}
67+
68+
- uses: actions/cache@v3
69+
with:
70+
path: ~/.m2/repository
71+
key: ${{ matrix.os }}-maven-${{ hashFiles('**/pom.xml') }}
72+
restore-keys: |
73+
${{ matrix.os }}-maven-
74+
75+
- name: Build and test with maven
76+
# Skip all static checks, they were already done in the compile jobs
77+
run: mvn -B --errors --activate-profiles ci --no-transfer-progress package
78+
79+
- name: Archive test results and logs
80+
# if: success() || failure() to also get the test results on successful runs.
81+
if: failure()
82+
uses: actions/upload-artifact@v3
83+
with:
84+
name: test-results-${{ matrix.java }}-${{ matrix.os }}
85+
path: sshd-*/target/surefire-*

‎.github/workflows/master-build.yml

+6-67
Original file line numberDiff line numberDiff line change
@@ -15,84 +15,23 @@
1515
# limitations under the License.
1616
#
1717

18-
name: build
18+
name: master-build
1919

2020
on:
2121
push:
2222
branches:
2323
- master
24-
pull_request:
25-
branches:
26-
- master
2724

2825
jobs:
29-
compile:
30-
runs-on: ${{ matrix.os }}
31-
strategy:
32-
matrix:
33-
os: [ ubuntu-latest, windows-latest ]
34-
java: [ '8' ]
35-
steps:
36-
- uses: actions/checkout@v3
37-
38-
- name: Set up JDK ${{ matrix.java }}
39-
uses: actions/setup-java@v3
40-
with:
41-
distribution: temurin
42-
java-version: ${{ matrix.java }}
43-
44-
- uses: actions/cache@v3
45-
with:
46-
path: ~/.m2/repository
47-
key: ${{ matrix.os }}-maven-${{ hashFiles('**/pom.xml') }}
48-
restore-keys: |
49-
${{ matrix.os }}-maven-
50-
51-
- name: Build with maven
52-
run: mvn -B --errors --activate-profiles ci --no-transfer-progress package -DskipTests
53-
54-
test:
55-
needs: compile
56-
runs-on: ${{ matrix.os }}
57-
strategy:
58-
matrix:
59-
os: [ ubuntu-latest, windows-latest ]
60-
java: [ '8', '11', '17' ]
61-
steps:
62-
- uses: actions/checkout@v3
63-
64-
- name: Set up JDK ${{ matrix.java }}
65-
uses: actions/setup-java@v3
66-
with:
67-
distribution: temurin
68-
java-version: ${{ matrix.java }}
69-
70-
- uses: actions/cache@v3
71-
with:
72-
path: ~/.m2/repository
73-
key: ${{ matrix.os }}-maven-${{ hashFiles('**/pom.xml') }}
74-
restore-keys: |
75-
${{ matrix.os }}-maven-
76-
77-
- name: Build and test with maven
78-
# Skip all static checks, they were already done in the compile jobs
79-
run: mvn -B --errors --activate-profiles ci --no-transfer-progress package
80-
81-
- name: Archive test results and logs
82-
# if: success() || failure() to also get the test results on successful runs.
83-
if: failure()
84-
uses: actions/upload-artifact@v3
85-
with:
86-
name: test-results-${{ matrix.java }}-${{ matrix.os }}
87-
path: sshd-*/target/surefire-*
26+
build:
27+
uses: ./.github/workflows/build.yml
8828

8929
deploy-snapshot:
90-
# Run only on pushes or PR merges to the master branch, but not on PRs themselves.
91-
# Also skip any commit from creating releases. The first snapshot after a new release
30+
# Skip any commit from creating releases. The first snapshot after a new release
9231
# will thus be published on the first real change on the new snapshot version, but
9332
# there will be no snapshot release for just bumping the version.
94-
if: "github.event_name == 'push' && github.ref == 'refs/heads/master' && !startsWith(github.event.head_commit.message ,'[maven-release-plugin]')"
95-
needs: test
33+
if: "!startsWith(github.event.head_commit.message ,'[maven-release-plugin]')"
34+
needs: build
9635
# Serialize these jobs from different workflow runs. We do not want concurrent
9736
# deployments. We don't cancel already running jobs because we do not want their
9837
# workflows to report a failure. Github does not guarantee order between jobs

0 commit comments

Comments
 (0)