Skip to content

Commit 2eade4a

Browse files
Add github actions build and unit tests
1 parent 7ef5f7c commit 2eade4a

File tree

3 files changed

+125
-19
lines changed

3 files changed

+125
-19
lines changed

.github/workflows/build.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Copyright © 2022 Cask Data, Inc.
2+
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
3+
# use this file except in compliance with the License. You may obtain a copy of
4+
# the License at
5+
# http://www.apache.org/licenses/LICENSE-2.0
6+
# Unless required by applicable law or agreed to in writing, software
7+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
8+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
9+
# License for the specific language governing permissions and limitations under
10+
# the License.
11+
12+
# This workflow will build a Java project with Maven
13+
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
14+
# Note: Any changes to this workflow would be used only after merging into develop
15+
name: Build with unit tests
16+
17+
on:
18+
workflow_run:
19+
workflows:
20+
- Trigger build
21+
types:
22+
- completed
23+
24+
jobs:
25+
build:
26+
runs-on: k8s-runner-build
27+
28+
if: ${{ github.event.workflow_run.conclusion != 'skipped' }}
29+
30+
steps:
31+
# Pinned 1.0.0 version
32+
- uses: haya14busa/action-workflow_run-status@967ed83efa565c257675ed70cfe5231f062ddd94
33+
34+
- uses: actions/[email protected]
35+
with:
36+
ref: ${{ github.event.workflow_run.head_sha }}
37+
38+
- name: Cache
39+
uses: actions/[email protected]
40+
with:
41+
path: ~/.m2/repository
42+
key: ${{ runner.os }}-maven-${{ github.workflow }}-${{ hashFiles('**/pom.xml') }}
43+
restore-keys: |
44+
${{ runner.os }}-maven-${{ github.workflow }}
45+
46+
- name: Build with Maven
47+
run: mvn clean test -fae -T 2 -B -V -Dmaven.wagon.http.retryHandler.count=3 -Dmaven.wagon.httpconnectionManager.ttlSeconds=25
48+
49+
- name: Archive build artifacts
50+
uses: actions/[email protected]
51+
if: always()
52+
with:
53+
name: Build debug files
54+
path: |
55+
**/target/rat.txt
56+
**/target/surefire-reports/*
57+
58+
- name: Surefire Report
59+
# Pinned 1.0.5 version
60+
uses: ScaCap/action-surefire-report@ad808943e6bfbd2e6acba7c53fdb5c89534da533
61+
if: always()
62+
with:
63+
# GITHUB_TOKEN
64+
github_token: ${{ secrets.GITHUB_TOKEN }}
65+
commit: ${{ github.event.workflow_run.head_sha }}

.github/workflows/e2e.yml

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,15 @@
1515
name: Build e2e tests
1616

1717
on:
18-
push:
19-
branches: [ develop ]
20-
pull_request:
21-
branches: [ develop ]
22-
types: [opened, synchronize, reopened, labeled]
23-
workflow_dispatch:
18+
workflow_run:
19+
workflows:
20+
- Trigger build
21+
types:
22+
- completed
2423

2524
jobs:
2625
build:
2726
runs-on: k8s-runner-e2e
28-
# We allow builds:
29-
# 1) When triggered manually
30-
# 2) When it's a merge into a branch
31-
# 3) For PRs that are labeled as build and
32-
# - It's a code change
33-
# - A build label was just added
34-
# A bit complex, but prevents builds when other labels are manipulated
35-
if: >
36-
github.event_name == 'workflow_dispatch'
37-
|| github.event_name == 'push'
38-
|| (contains(github.event.pull_request.labels.*.name, 'build')
39-
&& (github.event.action != 'labeled' || github.event.label.name == 'build')
40-
)
4127
strategy:
4228
matrix:
4329
module: [mysql-plugin, postgresql-plugin]
@@ -48,6 +34,8 @@ jobs:
4834
with:
4935
path: plugin
5036
submodules: 'recursive'
37+
ref: ${{ github.event.workflow_run.head_sha }}
38+
5139
- uses: dorny/paths-filter@b2feaf19c27470162a626bd6fa8438ae5b263721
5240
if: github.event_name != 'workflow_dispatch' && github.event_name != 'push'
5341
id: filter
@@ -56,36 +44,43 @@ jobs:
5644
filters: |
5745
e2e-test:
5846
- '${{ matrix.module }}/**/e2e-test/**'
47+
5948
- name: Checkout e2e test repo
6049
uses: actions/[email protected]
6150
with:
6251
repository: cdapio/cdap-e2e-tests
6352
path: e2e
53+
6454
- name: Cache
6555
uses: actions/[email protected]
6656
with:
6757
path: ~/.m2/repository
6858
key: ${{ runner.os }}-maven-${{ github.workflow }}-${{ hashFiles('**/pom.xml') }}
6959
restore-keys: |
7060
${{ runner.os }}-maven-${{ github.workflow }}
61+
7162
- name: Run required e2e tests
7263
if: github.event_name != 'workflow_dispatch' && github.event_name != 'push' && steps.filter.outputs.e2e-test == 'false'
7364
run: python3 e2e/src/main/scripts/run_e2e_test.py --module ${{ matrix.module }} --testRunner TestRunnerRequired.java
65+
7466
- name: Run all e2e tests
7567
if: github.event_name == 'workflow_dispatch' || github.event_name == 'push' || steps.filter.outputs.e2e-test == 'true'
7668
run: python3 e2e/src/main/scripts/run_e2e_test.py --module ${{ matrix.module }}
69+
7770
- name: Upload report
7871
uses: actions/[email protected]
7972
if: always()
8073
with:
8174
name: Cucumber report - ${{ matrix.module }}
8275
path: ./**/target/cucumber-reports
76+
8377
- name: Upload debug files
8478
uses: actions/[email protected]
8579
if: always()
8680
with:
8781
name: Debug files - ${{ matrix.module }}
8882
path: ./**/target/e2e-debug
83+
8984
- name: Upload files to GCS
9085
uses: google-github-actions/upload-cloud-storage@v0
9186
if: always()

.github/workflows/trigger.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Copyright © 2022 Cask Data, Inc.
2+
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
3+
# use this file except in compliance with the License. You may obtain a copy of
4+
# the License at
5+
# http://www.apache.org/licenses/LICENSE-2.0
6+
# Unless required by applicable law or agreed to in writing, software
7+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
8+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
9+
# License for the specific language governing permissions and limitations under
10+
# the License.
11+
12+
# This workflow will trigger build.yml only when needed.
13+
# This way we don't flood main workflow run list
14+
# Note that build.yml from develop will be used even for PR builds
15+
# Also it will have access to the proper GITHUB_SECRET
16+
17+
name: Trigger build
18+
19+
on:
20+
push:
21+
branches: [ develop, release/** ]
22+
pull_request:
23+
branches: [ develop, release/** ]
24+
types: [opened, synchronize, reopened, labeled]
25+
workflow_dispatch:
26+
27+
jobs:
28+
trigger:
29+
runs-on: ubuntu-latest
30+
31+
# We allow builds:
32+
# 1) When triggered manually
33+
# 2) When it's a merge into a branch
34+
# 3) For PRs that are labeled as build and
35+
# - It's a code change
36+
# - A build label was just added
37+
# A bit complex, but prevents builds when other labels are manipulated
38+
if: >
39+
github.event_name == 'workflow_dispatch'
40+
|| github.event_name == 'push'
41+
|| (contains(github.event.pull_request.labels.*.name, 'build')
42+
&& (github.event.action != 'labeled' || github.event.label.name == 'build')
43+
)
44+
steps:
45+
- name: Trigger build
46+
run: echo Maven build will be triggered now

0 commit comments

Comments
 (0)