From 4a0fc571f92c4a6dbb2cf6eb23d2fe70f52d97d8 Mon Sep 17 00:00:00 2001 From: Matthew B White Date: Wed, 14 Dec 2022 14:09:26 +0000 Subject: [PATCH] GHA workflow Signed-off-by: Matthew B White --- .github/workflows/build.yaml | 91 ++++++++++++++++++++++++++++++------ test/fv/ledger.js | 2 +- 2 files changed, 79 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 8007dbea1..ff40b4b4a 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -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,7 +178,7 @@ 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/') @@ -156,8 +186,7 @@ jobs: - 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 }} - \ No newline at end of file + 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 }} diff --git a/test/fv/ledger.js b/test/fv/ledger.js index 644365b83..02ae88bd5 100755 --- a/test/fv/ledger.js +++ b/test/fv/ledger.js @@ -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';