Skip to content

Commit a41d1e0

Browse files
authored
Merge pull request #294 from bestbeforetoday/schedule
Add scheduled builds
2 parents 5c9277f + c3b1f02 commit a41d1e0

6 files changed

Lines changed: 244 additions & 146 deletions

File tree

.github/workflows/build.yml

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

.github/workflows/pull_request.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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+
- main
10+
- release-2.5
11+
workflow_dispatch:
12+
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
15+
cancel-in-progress: true
16+
17+
jobs:
18+
test:
19+
uses: ./.github/workflows/test.yml
20+
21+
pull-request:
22+
needs: test
23+
name: Pull request success
24+
runs-on: ubuntu-latest
25+
steps:
26+
- run: true

.github/workflows/push.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
- main
10+
- release-2.5
11+
workflow_dispatch:
12+
13+
jobs:
14+
test:
15+
uses: ./.github/workflows/test.yml

.github/workflows/release.yml

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# Copyright the Hyperledger Fabric contributors. All rights reserved.
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
name: Release
6+
7+
on:
8+
create:
9+
tags:
10+
- '*'
11+
workflow_dispatch:
12+
13+
jobs:
14+
test:
15+
uses: ./.github/workflows/test.yaml
16+
17+
# Publishing steps to both the Github Packages and the Sonatype
18+
publishjars:
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
publish_target: ["publishAllPublicationsToGithubPackagesRepository","publishAllPublicationsToReleaseRepository"]
23+
runs-on: ubuntu-latest
24+
needs: test
25+
steps:
26+
- uses: actions/checkout@v3
27+
- uses: actions/setup-java@v3
28+
with:
29+
distribution: 'temurin'
30+
java-version: '11'
31+
cache: 'gradle'
32+
- name: Validate Gradle wrapper
33+
uses: gradle/wrapper-validation-action@v1.0.5
34+
- name: Push to registry ${{ matrix.publish_target }}
35+
run: |
36+
set -xev
37+
./gradlew -Psigning.key="${SIGNING_KEY}" -Psigning.password="${SIGNING_PASSWORD}" -PossrhUsername="${OSSRH_USER}" -PossrhPassword="${OSSRH_PASSWORD}" ${TARGET}
38+
env:
39+
SIGNING_PASSWORD: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}
40+
SIGNING_KEY: ${{ secrets.OSSRH_GPG_SECRET_KEY }}
41+
OSSRH_USER: ${{ secrets.OSSRH_USERNAME }}
42+
OSSRH_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
43+
TARGET: ${{ matrix.publish_target }}
44+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
46+
# Publish to docker registries docker.io and ghcr.io
47+
publishdocker:
48+
strategy:
49+
fail-fast: false
50+
matrix:
51+
DOCKER_REGISTRY: ["docker.io","ghcr.io"]
52+
runs-on: ubuntu-latest
53+
needs: test
54+
permissions:
55+
contents: read
56+
packages: write
57+
steps:
58+
- uses: actions/checkout@v3
59+
- uses: actions/setup-java@v3
60+
with:
61+
distribution: 'temurin'
62+
java-version: '11'
63+
cache: 'gradle'
64+
- name: Validate Gradle wrapper
65+
uses: gradle/wrapper-validation-action@v1.0.5
66+
- name: Build the depencies needed for the image
67+
uses: gradle/gradle-build-action@v2.3.3
68+
with:
69+
arguments: |
70+
:fabric-chaincode-docker:copyAllDeps -x dependencyCheckAnalyze
71+
- name: Set up QEMU
72+
uses: docker/setup-qemu-action@v2
73+
74+
- name: Set up Docker Buildx
75+
uses: docker/setup-buildx-action@v2
76+
with:
77+
buildkitd-flags: --debug
78+
config-inline: |
79+
[worker.oci]
80+
max-parallelism = 1
81+
- name: Login to the ${{ matrix.DOCKER_REGISTRY }} Container Registry
82+
uses: docker/login-action@v2
83+
with:
84+
registry: ${{ matrix.DOCKER_REGISTRY }}
85+
username: ${{ matrix.DOCKER_REGISTRY == 'docker.io' && secrets.DOCKERHUB_USERNAME || github.actor }}
86+
password: ${{ matrix.DOCKER_REGISTRY == 'docker.io' && secrets.DOCKERHUB_TOKEN || secrets.GITHUB_TOKEN }}
87+
88+
- name: Docker meta
89+
id: meta
90+
uses: docker/metadata-action@v4
91+
with:
92+
images: ${{ matrix.DOCKER_REGISTRY }}/${{ github.repository_owner }}/fabric-javaenv
93+
tags: |
94+
type=semver,pattern={{version}}
95+
type=semver,pattern={{major}}.{{minor}}
96+
type=semver,pattern={{major}}.{{minor}}.{{patch}}
97+
- name: Build and push ${{ matrix.COMPONENT }} Image
98+
id: push
99+
uses: docker/build-push-action@v3
100+
with:
101+
platforms: linux/amd64,linux/arm64
102+
file: fabric-chaincode-docker/Dockerfile
103+
context: fabric-chaincode-docker
104+
tags: ${{ steps.meta.outputs.tags }}
105+
push: ${{ github.event_name != 'pull_request' }}
106+
labels: ${{ steps.meta.outputs.labels }}

.github/workflows/schedule.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copyright the Hyperledger Fabric contributors. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
name: Scheduled build
5+
6+
on:
7+
schedule:
8+
- cron: "35 2 * * *"
9+
workflow_dispatch:
10+
11+
jobs:
12+
main:
13+
uses: ./.github/workflows/test.yml
14+
# Requires a test.yml to exist in the release-2.5 branch to implement the release-2.5 specific build/test steps, since
15+
# they are different from the main branch.
16+
#
17+
# release-2_5:
18+
# name: release-2.5
19+
# uses: hyperledger/fabric-chaincode-java/.github/workflows/test.yml@release-2.5
20+
# with:
21+
# checkout-ref: release-2.5

.github/workflows/test.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Copyright the Hyperledger Fabric contributors. All rights reserved.
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
name: Test
6+
7+
on:
8+
workflow_call:
9+
inputs:
10+
checkout-ref:
11+
default: ''
12+
required: false
13+
type: string
14+
15+
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@e6e38bacfdf1a337459f332974bb2327a31aaf4b
29+
- name: Dependency Check
30+
uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1
31+
with:
32+
arguments: |
33+
:fabric-chaincode-shim:dependencyCheckAnalyze
34+
- name: Build and Unit test
35+
uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1
36+
with:
37+
arguments: |
38+
:fabric-chaincode-shim:build
39+
-xdependencyCheckAnalyze
40+
41+
intergationtest:
42+
runs-on: ubuntu-latest
43+
steps:
44+
- uses: actions/checkout@v3
45+
with:
46+
ref: ${{ inputs.checkout-ref }}
47+
- uses: actions/setup-java@v3
48+
with:
49+
distribution: 'temurin'
50+
java-version: '11'
51+
cache: 'gradle'
52+
- name: Populate chaincode with latest java-version
53+
run: |
54+
./gradlew -I $GITHUB_WORKSPACE/fabric-chaincode-integration-test/chaincodebootstrap.gradle -PchaincodeRepoDir=$GITHUB_WORKSPACE/fabric-chaincode-integration-test/src/contracts/fabric-shim-api/repository publishShimJarPublicationToFabricRepository
55+
./gradlew -I $GITHUB_WORKSPACE/fabric-chaincode-integration-test/chaincodebootstrap.gradle -PchaincodeRepoDir=$GITHUB_WORKSPACE/fabric-chaincode-integration-test/src/contracts/fabric-ledger-api/repository publishShimJarPublicationToFabricRepository
56+
./gradlew -I $GITHUB_WORKSPACE/fabric-chaincode-integration-test/chaincodebootstrap.gradle -PchaincodeRepoDir=$GITHUB_WORKSPACE/fabric-chaincode-integration-test/src/contracts/bare-gradle/repository publishShimJarPublicationToFabricRepository
57+
./gradlew -I $GITHUB_WORKSPACE/fabric-chaincode-integration-test/chaincodebootstrap.gradle -PchaincodeRepoDir=$GITHUB_WORKSPACE/fabric-chaincode-integration-test/src/contracts/bare-maven/repository publishShimJarPublicationToFabricRepository
58+
./gradlew -I $GITHUB_WORKSPACE/fabric-chaincode-integration-test/chaincodebootstrap.gradle -PchaincodeRepoDir=$GITHUB_WORKSPACE/fabric-chaincode-integration-test/src/contracts/wrapper-maven/repository publishShimJarPublicationToFabricRepository
59+
- name: Ensure that the Peer/weft tools are available
60+
run: |
61+
curl -sSL https://raw.githubusercontent.com/hyperledger/fabric/main/scripts/install-fabric.sh | bash -s -- binary
62+
npm install -g @hyperledger-labs/weft
63+
64+
# set the path and cfg env var for the rest of the step
65+
echo "FABRIC_CFG_PATH=$GITHUB_WORKSPACE/config" >> $GITHUB_ENV
66+
echo "$GITHUB_WORKSPACE/bin" >> $GITHUB_PATH
67+
- name: versions
68+
run: |
69+
peer version
70+
weft --version
71+
- name: Integration Tests
72+
uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1
73+
with:
74+
arguments: |
75+
:fabric-chaincode-integration-test:build
76+
-xdependencyCheckAnalyze

0 commit comments

Comments
 (0)