Skip to content

Commit 4a0fc57

Browse files
mbwhitejt-nti
authored andcommitted
GHA workflow
Signed-off-by: Matthew B White <[email protected]>
1 parent 102473e commit 4a0fc57

File tree

2 files changed

+79
-14
lines changed

2 files changed

+79
-14
lines changed

.github/workflows/build.yaml

Lines changed: 78 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,40 @@ on:
1818
workflow_dispatch:
1919

2020
jobs:
21-
build:
21+
setup:
2222
runs-on: ubuntu-latest
23+
outputs:
24+
PACKAGE_VERSION: ${{ steps.builddata.outputs.PACKAGE_VERSION }}
25+
MINOR_PACKAGE_VERSION: ${{ steps.builddata.outputs.MINOR_PACKAGE_VERSION }}
26+
BUILD_DATE: ${{ steps.builddata.outputs.BUILD_DATE }}
27+
steps:
28+
- uses: actions/checkout@v3
29+
- uses: actions/setup-node@v3
30+
with:
31+
node-version: '16.x'
32+
- name: BuildData
33+
id: builddata
34+
run: |
35+
set -ex -o pipefail
36+
env | sort
37+
38+
# handle full version number
39+
VERSION=$(jq '.version' docker/fabric-nodeenv/package.json | sed -r "s/\"([0-9]?[0-9]\.[0-9]?[0-9]\.[0-9]?[0-9]).*/\1/")
40+
echo Current version in code is :${VERSION}:
41+
echo "PACKAGE_VERSION=${VERSION}" >> $GITHUB_OUTPUT
42+
43+
# handle minor version
44+
MINOR_VERSION=$(jq '.version' docker/fabric-nodeenv/package.json | sed -r "s/\"([0-9]?[0-9]\.[0-9]?[0-9])\.[0-9]?[0-9].*/\1/")
45+
echo Current minor version in code is :${MINOR_VERSION}:
46+
echo "MINOR_PACKAGE_VERSION=${MINOR_VERSION}" >> $GITHUB_OUTPUT
2347
48+
# get the current date for using in dev builds
49+
BUILD_DATE=$(date '+%Y%m%d')
50+
echo Build date is :${BUILD_DATE}
51+
echo "BUILD_DATE=${BUILD_DATE}" >> $GITHUB_OUTPUT
52+
53+
build:
54+
runs-on: ubuntu-latest
2455
strategy:
2556
matrix:
2657
node-version: [16.x]
@@ -41,6 +72,7 @@ jobs:
4172
npx cobertura-merge -o merged_coverage.xml shim=./libraries/fabric-shim/coverage/cobertura-coverage.xml contractapi=./apis/fabric-contract-api/coverage/cobertura-coverage.xml -p
4273
- uses: actions/upload-artifact@v3
4374
name: Upload test results
75+
if: success() || failure()
4476
with:
4577
name: TestResults
4678
path: ./**/test-results.xml
@@ -65,7 +97,7 @@ jobs:
6597

6698
fvtest:
6799
runs-on: ubuntu-latest
68-
needs: build
100+
needs: [build]
69101
strategy:
70102
matrix:
71103
node-version: [16.x]
@@ -86,6 +118,8 @@ jobs:
86118
path: build/
87119

88120
- name: Setup the fv build
121+
env:
122+
PIPELINE_WORKSPACE: workspace
89123
run: |
90124
set -xev
91125
./tools/getEdgeDocker.sh # essential to get main docker images of peer etc.
@@ -106,17 +140,13 @@ jobs:
106140
node common/scripts/install-run-rush.js test:fv --verbose
107141
node common/scripts/install-run-rush.js test:e2e --verbose
108142
109-
- name: upload results
110-
run: |
111-
set -xev
112-
mkdir -p testlogs
113-
find . \( -type d -name 'node_modules' \) -prune -o -name '*.build*.log' -exec cp {} testlogs \;
114143

115144
- uses: actions/upload-artifact@v3
145+
if: success() || failure()
116146
name: TestLogs
117147
with:
118148
name: TestLogs
119-
path: testlogs\
149+
path: ./**/*.build.log
120150

121151

122152
# Job to handle the auditing of the code
@@ -148,16 +178,15 @@ jobs:
148178
npm install --registry http://localhost:4873 fabric-shim fabric-shim-api fabric-contract-api --save
149179
npm audit --audit-level=moderate
150180
151-
publish:
181+
publishnpm:
152182
runs-on: ubuntu-latest
153183
needs: [build,fvtest,src_audit]
154184
if: startsWith(github.ref, 'refs/tags/')
155185
steps:
156186
- uses: actions/setup-node@v3
157187
with:
158188
node-version: '16.x'
159-
registry-url: 'https://npm.pkg.github.com'
160-
scope: '@mbwhite'
189+
registry-url: 'https://registry.npmjs.org'
161190
- uses: actions/download-artifact@v3
162191
with:
163192
name: node-tgzs
@@ -168,5 +197,41 @@ jobs:
168197
cd build
169198
find . -type f -name 'fabric-*.tgz' -exec npm publish {} \;
170199
env:
171-
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
172-
200+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
201+
202+
203+
publishdocker:
204+
runs-on: ubuntu-latest
205+
needs: [setup,build,fvtest,src_audit]
206+
if: startsWith(github.ref, 'refs/tags/')
207+
steps:
208+
- uses: actions/setup-node@v3
209+
with:
210+
node-version: '16.x'
211+
- uses: actions/download-artifact@v3
212+
with:
213+
name: nodeenv-docker-image
214+
path: build/
215+
- name: Push to registry
216+
run: |
217+
set -xev
218+
wget -qO "$PWD/manifest-tool" https://github.com/estesp/manifest-tool/releases/download/v1.0.0/manifest-tool-linux-amd64
219+
chmod +x ./manifest-tool
220+
221+
echo "Version strings are ${PACKAGE_VERSION} ${MINOR_PACKAGE_VERSION}"
222+
223+
docker image load --input build/fabric-javaenv.tar.gz
224+
docker images
225+
docker login ${DOCKER_REGISTRY_URL} --username=${DOCKER_REGISTRY_USERNAME} --password=${DOCKER_REGISTRY_PASSWORD}
226+
echo "Logged in to docker registry"
227+
# tag javaenv image to PACKAGE_VERSION
228+
docker tag hyperledger/fabric-javaenv hyperledger/fabric-nodeenv:amd64-${ PACKAGE_VERSION }
229+
# push javaenv to repository
230+
docker push hyperledger/fabric-javaenv:amd64-${ PACKAGE_VERSION }
231+
./manifest-tool push from-args --platforms linux/amd64 --template "hyperledger/fabric-nodeenv:amd64-${ PACKAGE_VERSION }" --target "hyperledger/fabric-nodeenv:${ PACKAGE_VERSION }"
232+
./manifest-tool push from-args --platforms linux/amd64 --template "hyperledger/fabric-nodeenv:amd64-${ PACKAGE_VERSION }" --target "hyperledger/fabric-nodeenv:${ MINOR_PACKAGE_VERSION }"
233+
env:
234+
DOCKER_REGISTRY_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
235+
DOCKER_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }}
236+
PACAKGE_VERSION: ${{ needs.setup.outputs.PACKAGE_VERSION }}
237+
MINOR_PACKAGE_VERSION: ${{ needs.setup.outputs.MINOR_PACKAGE_VERSION }}

test/fv/ledger.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const chai = require('chai');
99
chai.use(require('chai-as-promised'));
1010
const expect = chai.expect;
1111
const utils = require('./utils');
12-
const {LONG_STEP} = utils.TIMEOUTS;
12+
const {SHORT_STEP, MED_STEP, LONG_STEP} = utils.TIMEOUTS;
1313

1414
describe('Chaincode ledger', () => {
1515
const suite = 'ledger';

0 commit comments

Comments
 (0)