Skip to content

Commit

Permalink
GHA workflow
Browse files Browse the repository at this point in the history
Signed-off-by: Matthew B White <[email protected]>
mbwhite authored and jt-nti committed Dec 16, 2022
1 parent 102473e commit 4a0fc57
Showing 2 changed files with 79 additions and 14 deletions.
91 changes: 78 additions & 13 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -18,9 +18,40 @@ on:
workflow_dispatch:

jobs:
build:
setup:
runs-on: ubuntu-latest
outputs:
PACKAGE_VERSION: ${{ steps.builddata.outputs.PACKAGE_VERSION }}
MINOR_PACKAGE_VERSION: ${{ steps.builddata.outputs.MINOR_PACKAGE_VERSION }}
BUILD_DATE: ${{ steps.builddata.outputs.BUILD_DATE }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '16.x'
- name: BuildData
id: builddata
run: |
set -ex -o pipefail
env | sort
# handle full version number
VERSION=$(jq '.version' docker/fabric-nodeenv/package.json | sed -r "s/\"([0-9]?[0-9]\.[0-9]?[0-9]\.[0-9]?[0-9]).*/\1/")
echo Current version in code is :${VERSION}:
echo "PACKAGE_VERSION=${VERSION}" >> $GITHUB_OUTPUT
# handle minor version
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/")
echo Current minor version in code is :${MINOR_VERSION}:
echo "MINOR_PACKAGE_VERSION=${MINOR_VERSION}" >> $GITHUB_OUTPUT
# get the current date for using in dev builds
BUILD_DATE=$(date '+%Y%m%d')
echo Build date is :${BUILD_DATE}
echo "BUILD_DATE=${BUILD_DATE}" >> $GITHUB_OUTPUT
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x]
@@ -41,6 +72,7 @@ jobs:
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
- uses: actions/upload-artifact@v3
name: Upload test results
if: success() || failure()
with:
name: TestResults
path: ./**/test-results.xml
@@ -65,7 +97,7 @@ jobs:

fvtest:
runs-on: ubuntu-latest
needs: build
needs: [build]
strategy:
matrix:
node-version: [16.x]
@@ -86,6 +118,8 @@ jobs:
path: build/

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

- uses: actions/upload-artifact@v3
if: success() || failure()
name: TestLogs
with:
name: TestLogs
path: testlogs\
path: ./**/*.build.log


# Job to handle the auditing of the code
@@ -148,16 +178,15 @@ jobs:
npm install --registry http://localhost:4873 fabric-shim fabric-shim-api fabric-contract-api --save
npm audit --audit-level=moderate
publish:
publishnpm:
runs-on: ubuntu-latest
needs: [build,fvtest,src_audit]
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/setup-node@v3
with:
node-version: '16.x'
registry-url: 'https://npm.pkg.github.com'
scope: '@mbwhite'
registry-url: 'https://registry.npmjs.org'
- uses: actions/download-artifact@v3
with:
name: node-tgzs
@@ -168,5 +197,41 @@ jobs:
cd build
find . -type f -name 'fabric-*.tgz' -exec npm publish {} \;
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
publishdocker:
runs-on: ubuntu-latest
needs: [setup,build,fvtest,src_audit]
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/setup-node@v3
with:
node-version: '16.x'
- uses: actions/download-artifact@v3
with:
name: nodeenv-docker-image
path: build/
- name: Push to registry
run: |
set -xev
wget -qO "$PWD/manifest-tool" https://github.com/estesp/manifest-tool/releases/download/v1.0.0/manifest-tool-linux-amd64
chmod +x ./manifest-tool
echo "Version strings are ${PACKAGE_VERSION} ${MINOR_PACKAGE_VERSION}"
docker image load --input build/fabric-javaenv.tar.gz
docker images
docker login ${DOCKER_REGISTRY_URL} --username=${DOCKER_REGISTRY_USERNAME} --password=${DOCKER_REGISTRY_PASSWORD}
echo "Logged in to docker registry"
# tag javaenv image to PACKAGE_VERSION
docker tag hyperledger/fabric-javaenv hyperledger/fabric-nodeenv:amd64-${ PACKAGE_VERSION }
# push javaenv to repository
docker push hyperledger/fabric-javaenv:amd64-${ PACKAGE_VERSION }
./manifest-tool push from-args --platforms linux/amd64 --template "hyperledger/fabric-nodeenv:amd64-${ PACKAGE_VERSION }" --target "hyperledger/fabric-nodeenv:${ PACKAGE_VERSION }"
./manifest-tool push from-args --platforms linux/amd64 --template "hyperledger/fabric-nodeenv:amd64-${ PACKAGE_VERSION }" --target "hyperledger/fabric-nodeenv:${ MINOR_PACKAGE_VERSION }"
env:
DOCKER_REGISTRY_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKER_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }}
PACAKGE_VERSION: ${{ needs.setup.outputs.PACKAGE_VERSION }}
MINOR_PACKAGE_VERSION: ${{ needs.setup.outputs.MINOR_PACKAGE_VERSION }}
2 changes: 1 addition & 1 deletion test/fv/ledger.js
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ const chai = require('chai');
chai.use(require('chai-as-promised'));
const expect = chai.expect;
const utils = require('./utils');
const {LONG_STEP} = utils.TIMEOUTS;
const {SHORT_STEP, MED_STEP, LONG_STEP} = utils.TIMEOUTS;

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

0 comments on commit 4a0fc57

Please sign in to comment.