Skip to content

Commit

Permalink
Move to use NPM directly
Browse files Browse the repository at this point in the history
Signed-off-by: Matthew B White <whitemat@uk.ibm.com>
  • Loading branch information
mbwhite authored and jt-nti committed Mar 8, 2021
1 parent 4510e67 commit 54c27e7
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 107 deletions.
190 changes: 84 additions & 106 deletions ci/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ schedules:
branches:
include:
- master
always: true


# Trigger on the master branch
# Standard Pull Request and Merge builds
Expand Down Expand Up @@ -69,7 +67,12 @@ stages:
steps:
- task: NodeTool@0
inputs:
versionSpec: $(rewire_node_version_spec)
versionSpec: $(rewire_node_version_spec)
- script: |
set -ev
./ci/unstable-versions.sh
node common/scripts/install-run-rush.js update
condition: and(succeeded(), eq(variables['Build.Reason'], 'Schedule')) # only run on the scheduled builds
- script: |
set -ev
node common/scripts/install-run-rush.js install
Expand Down Expand Up @@ -120,67 +123,72 @@ stages:
artifactName: nodeenv-docker-image

# Run the FV tests but using the built material
# - job: fvt
# displayName: 'FV Tests'
# dependsOn: main
# steps:
# - task: NodeTool@0
# inputs:
# versionSpec: $(node_version_spec)
# - task: DownloadPipelineArtifact@2
# inputs:
# artifact: nodeenv-docker-image
# path: $(Build.SourcesDirectory)/build
# - task: DownloadPipelineArtifact@2
# inputs:
# artifact: node-tgz
# path: $(Build.SourcesDirectory)/build
# - script: |
# set -ev
# ./tools/getEdgeDocker.sh # essential to get master docker images of peer etc.
# docker image load --input build/fabric-nodeenv.tar.gz # gets the build image of nodeenv
# docker images
# node common/scripts/install-run-rush.js install
# node common/scripts/install-run-rush.js update # should the tests need 'building' this will need to go here
# displayName: 'Get the latest master docker images'
# - script: |
# set -ev
# node common/scripts/install-run-rush.js start-fabric
# node common/scripts/install-run-rush.js start-verdaccio # script will check for the ci variable and use built images
# docker images | grep hyperledger && docker ps -a
# node common/scripts/install-run-rush.js test:fv --verbose
# node common/scripts/install-run-rush.js test:e2e --verbose
# displayName: 'FV Tests'
- job: fvt
displayName: 'FV Tests'
dependsOn: main
steps:
- task: NodeTool@0
inputs:
versionSpec: $(node_version_spec)
- script: |
set -ev
./ci/unstable-versions.sh
node common/scripts/install-run-rush.js update
condition: and(succeeded(), eq(variables['Build.Reason'], 'Schedule')) # only run on the scheduled builds
- task: DownloadPipelineArtifact@2
inputs:
artifact: nodeenv-docker-image
path: $(Build.SourcesDirectory)/build
- task: DownloadPipelineArtifact@2
inputs:
artifact: node-tgz
path: $(Build.SourcesDirectory)/build
- script: |
set -ev
./tools/getEdgeDocker.sh # essential to get master docker images of peer etc.
docker image load --input build/fabric-nodeenv.tar.gz # gets the build image of nodeenv
docker images
node common/scripts/install-run-rush.js install
node common/scripts/install-run-rush.js update # should the tests need 'building' this will need to go here
displayName: 'Get the latest master docker images'
- script: |
set -ev
node common/scripts/install-run-rush.js start-fabric
node common/scripts/install-run-rush.js start-verdaccio # script will check for the ci variable and use built images
docker images | grep hyperledger && docker ps -a
node common/scripts/install-run-rush.js test:fv --verbose
node common/scripts/install-run-rush.js test:e2e --verbose
displayName: 'FV Tests'
# - task: PublishTestResults@2
# condition: or(succeeded(), failed()) # publish either way
# inputs:
# testResultsFiles: '**/test-results.xml'
# testRunTitle: 'FV Test results'
# - task: CopyFiles@2
# condition: or(succeeded(), failed()) # publish either way
# inputs:
# sourceFolder: $(Build.SourcesDirectory)/test
# contents: |
# **/*.build*.log
# !**/node_modules/**
# targetFolder: $(Build.ArtifactStagingDirectory)/testlogs
# - script: |
# mkdir -p $(Build.ArtifactStagingDirectory)/testlogs
# find . \( -type d -name 'node_modules' \) -prune -o -name '*.build*.log' -exec cp {} $(Build.ArtifactStagingDirectory)/testlogs \;
# condition: or(succeeded(), failed())
# displayName: 'Copy test logs'
# - task: PublishBuildArtifacts@1
# condition: or(succeeded(), failed()) # publish either way
# inputs:
# pathToPublish: $(Build.ArtifactStagingDirectory)/testlogs
# artifactName: 'Test logs'
# displayName: 'Publish test logs'
# - task: PublishBuildArtifacts@1
# condition: or(succeeded(), failed()) # publish either way
# inputs:
# pathToPublish: tools/toolchain/network/docker-compose/logs/docker.log
# artifactName: nodeenv-docker-image
- task: PublishTestResults@2
condition: or(succeeded(), failed()) # publish either way
inputs:
testResultsFiles: '**/test-results.xml'
testRunTitle: 'FV Test results'
- task: CopyFiles@2
condition: or(succeeded(), failed()) # publish either way
inputs:
sourceFolder: $(Build.SourcesDirectory)/test
contents: |
**/*.build*.log
!**/node_modules/**
targetFolder: $(Build.ArtifactStagingDirectory)/testlogs
- script: |
mkdir -p $(Build.ArtifactStagingDirectory)/testlogs
find . \( -type d -name 'node_modules' \) -prune -o -name '*.build*.log' -exec cp {} $(Build.ArtifactStagingDirectory)/testlogs \;
condition: or(succeeded(), failed())
displayName: 'Copy test logs'
- task: PublishBuildArtifacts@1
condition: or(succeeded(), failed()) # publish either way
inputs:
pathToPublish: $(Build.ArtifactStagingDirectory)/testlogs
artifactName: 'Test logs'
displayName: 'Publish test logs'
- task: PublishBuildArtifacts@1
condition: or(succeeded(), failed()) # publish either way
inputs:
pathToPublish: tools/toolchain/network/docker-compose/logs/docker.log
artifactName: nodeenv-docker-image


# Job to handle the auditing of the code
Expand All @@ -198,6 +206,10 @@ stages:
inputs:
artifact: node-tgz
path: $(Build.SourcesDirectory)/build
- script: |
set -ev
./ci/unstable-versions.sh
condition: and(succeeded(), eq(variables['Build.Reason'], 'Schedule')) # only run on the scheduled build
- script: |
node common/scripts/install-run-rush.js install
node common/scripts/install-run-rush.js start-verdaccio # script will check for the ci variable and use built images
Expand Down Expand Up @@ -328,11 +340,10 @@ stages:
DOCKER_REGISTRY_USERNAME: $(DockerHub-Username)
DOCKER_REGISTRY_PASSWORD: $(DockerHub-Password)
# Stage to publish the nightly drivers
# Stage to publish the nightly drivers
- stage: Publish_tag_nightly
dependsOn: Build_and_Test
# condition: and(succeeded(), eq(variables['Build.Reason'], 'Schedule')) # only run on the scheduled builds
condition: succeeded()
condition: and(succeeded(), eq(variables['Build.Reason'], 'Schedule')) # only run on the scheduled builds
jobs:
- job: npm_publish
displayName: 'npm publish'
Expand All @@ -346,47 +357,14 @@ stages:
touch $(Agent.TempDirectory)/.npmrc
echo '##vso[task.setvariable variable=NPM_CONFIG_USERCONFIG]$(Agent.TempDirectory)/.npmrc'
displayName: 'create user .npmrc file'
- script: |
set -ex -o pipefail
npm install -g npm-cli-login
npm-cli-login
npm config set registry https://registry.npmjs.org/
npm config ls
displayName: 'set npmjs registry'
env:
NPM_USER: $(ARTIFACTORY_USERNAME)
NPM_PASS: $(ARTIFACTORY_PASSWORD)
NPM_EMAIL: fabric@hyperledger.org
NPM_RC_PATH: $(Agent.TempDirectory)
NPM_REGISTRY: https://hyperledger.jfrog.io:8081/artifactory/fabric-npm/
- script: |
find $(Pipeline.Workspace)/node-tgz/ -maxdepth 1 -type f -name 'fabric-*.tgz' -exec npm publish {} --tag unstable \;
displayName: 'npm publish'
- job: dockerhub_publish
steps:
- template: templates/build-data.yaml
- task: DownloadPipelineArtifact@2
- task: npmAuthenticate@0
inputs:
artifact: nodeenv-docker-image
path: $(Build.SourcesDirectory)/build

workingFile: '$(Agent.TempDirectory)/.npmrc'
customEndpoint: 'fabric-chainode-node-npm'
- script: |
wget -qO "$PWD/manifest-tool" https://github.com/estesp/manifest-tool/releases/download/v1.0.0/manifest-tool-linux-amd64
chmod +x ./manifest-tool
docker image load --input build/fabric-nodeenv.tar.gz
docker images
docker login -u "${ARTIFACTORY_USERNAME}" -p "${ARTIFACTORY_PASSWORD}" hyperledger-fabric.jfrog.io
echo "Logged in to docker registry"
# tag nodeenv image to PACKAGE_VERSION
docker tag hyperledger/fabric-nodeenv hyperledger/fabric-nodeenv:amd64-$(BuildData.PACKAGE_VERSION)
# push nodeenv to repository
docker push hyperledger/fabric-nodeenv:amd64-$(BuildData.PACKAGE_VERSION)
# publish patch version (3-digit) image
./manifest-tool push from-args --platforms linux/amd64 --template "hyperledger/fabric-nodeenv:amd64-$(BuildData.PACKAGE_VERSION)" --target "hyperledger/fabric-nodeenv:$(BuildData.PACKAGE_VERSION)"
# publish minor version (2-digit) image
./manifest-tool push from-args --platforms linux/amd64 --template "hyperledger/fabric-nodeenv:amd64-$(BuildData.PACKAGE_VERSION)" --target "hyperledger/fabric-nodeenv:$(BuildData.MINOR_PACKAGE_VERSION)"
env:
DOCKER_REGISTRY_USERNAME: $(DockerHub-Username)
DOCKER_REGISTRY_PASSWORD: $(DockerHub-Password)
ARTIFACTORY_USERNAME: $(ARTIFACTORY_USERNAME)
ARTIFACTORY_PASSWORD: $(ARTIFACTORY_PASSWORD)
find $(Pipeline.Workspace)/node-tgz/ -maxdepth 1 -type f -name 'fabric-*.tgz' -exec npm publish {} --tag unstable \;
displayName: 'npm publish'
36 changes: 36 additions & 0 deletions ci/unstable-versions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash
set -e -o pipefail

# Root of the version that we will be looking for and publishing on
RELEASE_VERSION=2.3.1-snapshot

# get the currently published versions, pull out the versions
V=$(npm view fabric-contract-api --json | jq -r --arg VER ${RELEASE_VERSION} '.versions[] | select(test($VER))' | awk -F"." '{print $4+1}' | sort -n | tail -1)
FULL_VERSION=${RELEASE_VERSION}.${V:-1}

F=$(find . -wholename "./apis/**/package.json" -or -wholename "./libraries/**/package.json" -or -wholename "./test/**/package.json")
for PACKAGE_JSON in $F
do
# jq --arg ver $FULL_VERSION '.version=$ver' ${pf} | sponge ${pf}
export PACKAGE_JSON
export FULL_VERSION
node - << EOF
const fs = require('fs')
let input = JSON.parse(fs.readFileSync(process.env.PACKAGE_JSON));
let ver = process.env.FULL_VERSION;
input.version=ver;
if (input.dependencies){
if (input.dependencies['fabric-contract-api']) input.dependencies['fabric-contract-api']=ver;
if (input.dependencies['fabric-ledger']) input.dependencies['fabric-ledger']=ver;
if (input.dependencies['fabric-shim']) input.dependencies['fabric-shim']=ver;
if (input.dependencies['fabric-shim-api']) input.dependencies['fabric-shim-api']=ver;
if (input.dependencies['fabric-shim-crypto']) input.dependencies['fabric-shim-crypto']=ver;
}
fs.writeFileSync(process.env.PACKAGE_JSON,JSON.stringify(input,null,2));
EOF

done




1 change: 0 additions & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"docs": "rimraf ./gen && jsdoc -c ./_jsdoc.json"
},
"devDependencies": {
"fabric-ledger": "2.3.1-unstable",
"ink-docstrap": "^1.3.2",
"jsdoc": "^3.6.3",
"rimraf": "^3.0.0"
Expand Down

0 comments on commit 54c27e7

Please sign in to comment.