Skip to content

Commit 575f937

Browse files
authored
Merge pull request #296 from bestbeforetoday/gha
Refactor of GitHub Actions workflows for consistency with main
2 parents c835610 + be07a11 commit 575f937

5 files changed

Lines changed: 94 additions & 82 deletions

File tree

.github/workflows/pr.yml

Lines changed: 0 additions & 50 deletions
This file was deleted.

.github/workflows/pull_request.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright the Hyperledger Fabric contributors. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
name: Pull request
5+
6+
on:
7+
pull_request:
8+
branches:
9+
- release-2.5
10+
workflow_dispatch:
11+
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
test:
18+
uses: ./.github/workflows/test.yml
19+
20+
pull-request:
21+
needs: test
22+
name: Pull request success
23+
runs-on: ubuntu-latest
24+
steps:
25+
- run: true

.github/workflows/push.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Copyright the Hyperledger Fabric contributors. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
name: Push
5+
6+
on:
7+
push:
8+
branches:
9+
- release-2.5
10+
workflow_dispatch:
11+
12+
jobs:
13+
test:
14+
uses: ./.github/workflows/test.yml
Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,28 @@
22
#
33
# SPDX-License-Identifier: Apache-2.0
44

5+
name: Release
56

6-
# Workflow will only run on tag creation. It will run the integration tests first to confirm that the build is sound and then
7-
# and only then do the publishing
8-
name: Publish Workflow
97
on:
108
create:
119
tags:
12-
- "*"
10+
- '*'
1311
workflow_dispatch:
14-
12+
1513
jobs:
16-
17-
# Run the integration tests on the repo, before moving to the publishing.
18-
# Run the integration tests on the repo
19-
publish_call_intergationtest:
20-
uses: ./.github/workflows/integrationtest.yml
14+
test:
15+
uses: ./.github/workflows/test.yaml
2116

22-
2317
# Publishing steps to both the Github Packages and the Sonatype
2418
publishjars:
2519
strategy:
2620
fail-fast: false
2721
matrix:
28-
publish_target: ["publishAllPublicationsToGithubPackagesRepository","publishAllPublicationsToReleaseRepository"]
22+
publish_target:
23+
- publishAllPublicationsToGithubPackagesRepository
24+
- publishAllPublicationsToReleaseRepository
2925
runs-on: ubuntu-latest
30-
needs: [publish_call_intergationtest]
26+
needs: test
3127
steps:
3228
- uses: actions/checkout@v3
3329
- uses: actions/setup-java@v3
@@ -36,12 +32,12 @@ jobs:
3632
java-version: '11'
3733
cache: 'gradle'
3834
- name: Validate Gradle wrapper
39-
uses: gradle/wrapper-validation-action@v1.0.5
35+
uses: gradle/wrapper-validation-action@v1
4036
- name: Push to registry ${{ matrix.publish_target }}
4137
run: |
4238
set -xev
4339
./gradlew -Psigning.key="${SIGNING_KEY}" -Psigning.password="${SIGNING_PASSWORD}" -PossrhUsername="${OSSRH_USER}" -PossrhPassword="${OSSRH_PASSWORD}" ${TARGET}
44-
env:
40+
env:
4541
SIGNING_PASSWORD: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}
4642
SIGNING_KEY: ${{ secrets.OSSRH_GPG_SECRET_KEY }}
4743
OSSRH_USER: ${{ secrets.OSSRH_USERNAME }}
@@ -54,9 +50,11 @@ jobs:
5450
strategy:
5551
fail-fast: false
5652
matrix:
57-
DOCKER_REGISTRY: ["docker.io","ghcr.io"]
53+
DOCKER_REGISTRY:
54+
- 'docker.io'
55+
- 'ghcr.io'
5856
runs-on: ubuntu-latest
59-
needs: [publish_call_intergationtest]
57+
needs: test
6058
permissions:
6159
contents: read
6260
packages: write
@@ -68,31 +66,27 @@ jobs:
6866
java-version: '11'
6967
cache: 'gradle'
7068
- name: Validate Gradle wrapper
71-
uses: gradle/wrapper-validation-action@v1.0.5
72-
- name: Build the depencies needed for the image
73-
uses: gradle/gradle-build-action@v2.3.3
69+
uses: gradle/wrapper-validation-action@v1
70+
- name: Build the dependencies needed for the image
71+
uses: gradle/gradle-build-action@v2
7472
with:
75-
arguments: |
76-
:fabric-chaincode-docker:copyAllDeps -x dependencyCheckAnalyze
77-
73+
arguments: |
74+
:fabric-chaincode-docker:copyAllDeps -x dependencyCheckAnalyze
7875
- name: Set up QEMU
7976
uses: docker/setup-qemu-action@v2
80-
8177
- name: Set up Docker Buildx
8278
uses: docker/setup-buildx-action@v2
8379
with:
8480
buildkitd-flags: --debug
8581
config-inline: |
8682
[worker.oci]
8783
max-parallelism = 1
88-
8984
- name: Login to the ${{ matrix.DOCKER_REGISTRY }} Container Registry
9085
uses: docker/login-action@v2
9186
with:
9287
registry: ${{ matrix.DOCKER_REGISTRY }}
9388
username: ${{ matrix.DOCKER_REGISTRY == 'docker.io' && secrets.DOCKERHUB_USERNAME || github.actor }}
9489
password: ${{ matrix.DOCKER_REGISTRY == 'docker.io' && secrets.DOCKERHUB_TOKEN || secrets.GITHUB_TOKEN }}
95-
9690
- name: Docker meta
9791
id: meta
9892
uses: docker/metadata-action@v4
@@ -112,4 +106,3 @@ jobs:
112106
tags: ${{ steps.meta.outputs.tags }}
113107
push: ${{ github.event_name != 'pull_request' }}
114108
labels: ${{ steps.meta.outputs.labels }}
115-
Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,60 @@
22
#
33
# SPDX-License-Identifier: Apache-2.0
44

5-
name: Reusable Integration Test workflow
5+
name: Test
66

77
on:
88
workflow_call:
9+
inputs:
10+
checkout-ref:
11+
default: ''
12+
required: false
13+
type: string
914

1015
jobs:
16+
build:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v3
20+
with:
21+
ref: ${{ inputs.checkout-ref }}
22+
- uses: actions/setup-java@v3
23+
with:
24+
distribution: 'temurin'
25+
java-version: '11'
26+
cache: 'gradle'
27+
- name: Validate Gradle wrapper
28+
uses: gradle/wrapper-validation-action@v1
29+
- name: Dependency Check
30+
uses: gradle/gradle-build-action@v2
31+
with:
32+
arguments: |
33+
:fabric-chaincode-shim:dependencyCheckAnalyze
34+
- name: Build and Unit test
35+
uses: gradle/gradle-build-action@v2
36+
with:
37+
arguments: |
38+
:fabric-chaincode-shim:build
39+
-xdependencyCheckAnalyze
40+
1141
intergationtest:
1242
runs-on: ubuntu-latest
1343
steps:
1444
- uses: actions/checkout@v3
45+
with:
46+
ref: ${{ inputs.checkout-ref }}
1547
- uses: actions/setup-java@v3
1648
with:
1749
distribution: 'temurin'
1850
java-version: '11'
1951
cache: 'gradle'
20-
2152
- name: Populate chaincode with latest java-version
2253
run: |
2354
./gradlew -I $GITHUB_WORKSPACE/fabric-chaincode-integration-test/chaincodebootstrap.gradle -PchaincodeRepoDir=$GITHUB_WORKSPACE/fabric-chaincode-integration-test/src/contracts/fabric-shim-api/repository publishShimPublicationToFabricRepository
2455
./gradlew -I $GITHUB_WORKSPACE/fabric-chaincode-integration-test/chaincodebootstrap.gradle -PchaincodeRepoDir=$GITHUB_WORKSPACE/fabric-chaincode-integration-test/src/contracts/fabric-ledger-api/repository publishShimPublicationToFabricRepository
2556
./gradlew -I $GITHUB_WORKSPACE/fabric-chaincode-integration-test/chaincodebootstrap.gradle -PchaincodeRepoDir=$GITHUB_WORKSPACE/fabric-chaincode-integration-test/src/contracts/bare-gradle/repository publishShimPublicationToFabricRepository
2657
./gradlew -I $GITHUB_WORKSPACE/fabric-chaincode-integration-test/chaincodebootstrap.gradle -PchaincodeRepoDir=$GITHUB_WORKSPACE/fabric-chaincode-integration-test/src/contracts/bare-maven/repository publishShimPublicationToFabricRepository
2758
./gradlew -I $GITHUB_WORKSPACE/fabric-chaincode-integration-test/chaincodebootstrap.gradle -PchaincodeRepoDir=$GITHUB_WORKSPACE/fabric-chaincode-integration-test/src/contracts/wrapper-maven/repository publishShimPublicationToFabricRepository
28-
2959
- name: Ensure that the Peer/weft tools are available
3060
run: |
3161
curl -sSL https://raw.githubusercontent.com/hyperledger/fabric/main/scripts/install-fabric.sh | bash -s -- binary
@@ -39,8 +69,8 @@ jobs:
3969
peer version
4070
weft --version
4171
- name: Integration Tests
42-
uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1
72+
uses: gradle/gradle-build-action@v2
4373
with:
4474
arguments: |
4575
:fabric-chaincode-integration-test:build
46-
-xdependencyCheckAnalyze
76+
-xdependencyCheckAnalyze

0 commit comments

Comments
 (0)