From 9edbe9851ff795e0dc00fc3e2527c573fe2747ff Mon Sep 17 00:00:00 2001 From: Josh Kneubuhl Date: Mon, 14 Nov 2022 21:51:42 -0500 Subject: [PATCH] Port remaining sample tests from Azure -> GHA Signed-off-by: Josh Kneubuhl --- .github/workflows/rest-sample.yaml | 42 +++++++++ .github/workflows/test-network-events.yaml | 37 ++++++++ .github/workflows/test-network-ledger.yaml | 37 ++++++++ .github/workflows/test-network-private.yaml | 36 ++++++++ .github/workflows/test-network-sbe.yaml | 37 ++++++++ .github/workflows/test-network-secured.yaml | 36 ++++++++ .github/workflows/test-network.yaml | 4 +- ci/azure-pipelines.yml | 85 ------------------- .../azure-pipelines-rest.yml | 11 +-- ci/templates/install-deps-hsm.yml | 13 --- ci/templates/install-deps.yml | 17 ---- ci/templates/install-k8s-deps.yml | 9 -- 12 files changed, 229 insertions(+), 135 deletions(-) create mode 100644 .github/workflows/rest-sample.yaml create mode 100644 .github/workflows/test-network-events.yaml create mode 100644 .github/workflows/test-network-ledger.yaml create mode 100644 .github/workflows/test-network-private.yaml create mode 100644 .github/workflows/test-network-sbe.yaml create mode 100644 .github/workflows/test-network-secured.yaml delete mode 100644 ci/templates/install-deps-hsm.yml delete mode 100644 ci/templates/install-deps.yml delete mode 100644 ci/templates/install-k8s-deps.yml diff --git a/.github/workflows/rest-sample.yaml b/.github/workflows/rest-sample.yaml new file mode 100644 index 00000000..e5184067 --- /dev/null +++ b/.github/workflows/rest-sample.yaml @@ -0,0 +1,42 @@ +# +# SPDX-License-Identifier: Apache-2.0 +# +name: REST Sample +run-name: ${{ github.actor }} is testing the REST Sample + +env: + NODE_VER: 16.x + +on: + workflow_dispatch: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + rest-sample: + runs-on: ubuntu-20.04 + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODE_VER }} + cache: 'npm' + cache-dependency-path: '**/package-lock.json' + + - name: Install REST Sample Dependencies + working-directory: asset-transfer-basic/rest-api-typescript + run: npm install + + - name: Build REST Sample Application + run: npm run build + working-directory: asset-transfer-basic/rest-api-typescript + + - name: Test REST Sample Application + run: npm test + working-directory: asset-transfer-basic/rest-api-typescript + diff --git a/.github/workflows/test-network-events.yaml b/.github/workflows/test-network-events.yaml new file mode 100644 index 00000000..78155e5e --- /dev/null +++ b/.github/workflows/test-network-events.yaml @@ -0,0 +1,37 @@ +# +# SPDX-License-Identifier: Apache-2.0 +# +name: Test Network Events +run-name: ${{ github.actor }} is running the Test Network Events tests + +on: + workflow_dispatch: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + events: + runs-on: ubuntu-20.04 + strategy: + matrix: + chaincode-language: + - javascript + - java + chaincode-name: + - events + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set up the test network runtime + uses: ./.github/actions/test-network-setup + + - name: Run Test + working-directory: test-network + run: ../ci/scripts/run-test-network-events.sh + env: + CHAINCODE_NAME: ${{ matrix.chaincode-name }} + CHAINCODE_LANGUAGE: ${{ matrix.chaincode-language }} + diff --git a/.github/workflows/test-network-ledger.yaml b/.github/workflows/test-network-ledger.yaml new file mode 100644 index 00000000..91931c8c --- /dev/null +++ b/.github/workflows/test-network-ledger.yaml @@ -0,0 +1,37 @@ +# +# SPDX-License-Identifier: Apache-2.0 +# +name: Test Network Ledger +run-name: ${{ github.actor }} is running the Test Network Ledger tests + +on: + workflow_dispatch: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + basic: + runs-on: ubuntu-20.04 + strategy: + matrix: + chaincode-language: + - go + - javascript + chaincode-name: + - ledger + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set up the test network runtime + uses: ./.github/actions/test-network-setup + + - name: Run Test + working-directory: test-network + run: ../ci/scripts/run-test-network-ledger.sh + env: + CHAINCODE_NAME: ${{ matrix.chaincode-name }} + CHAINCODE_LANGUAGE: ${{ matrix.chaincode-language }} + diff --git a/.github/workflows/test-network-private.yaml b/.github/workflows/test-network-private.yaml new file mode 100644 index 00000000..43f00957 --- /dev/null +++ b/.github/workflows/test-network-private.yaml @@ -0,0 +1,36 @@ +# +# SPDX-License-Identifier: Apache-2.0 +# +name: Test Network Private +run-name: ${{ github.actor }} is running the Test Network Private tests + +on: + workflow_dispatch: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + private: + runs-on: ubuntu-20.04 + strategy: + matrix: + chaincode-language: + - go + chaincode-name: + - private + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set up the test network runtime + uses: ./.github/actions/test-network-setup + + - name: Run Test + working-directory: test-network + run: ../ci/scripts/run-test-network-private.sh + env: + CHAINCODE_NAME: ${{ matrix.chaincode-name }} + CHAINCODE_LANGUAGE: ${{ matrix.chaincode-language }} + diff --git a/.github/workflows/test-network-sbe.yaml b/.github/workflows/test-network-sbe.yaml new file mode 100644 index 00000000..37bef7a2 --- /dev/null +++ b/.github/workflows/test-network-sbe.yaml @@ -0,0 +1,37 @@ +# +# SPDX-License-Identifier: Apache-2.0 +# +name: Test Network SBE +run-name: ${{ github.actor }} is running the Test Network SBE tests + +on: + workflow_dispatch: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + SBE: + runs-on: ubuntu-20.04 + strategy: + matrix: + chaincode-language: + - typescript + - java + chaincode-name: + - sbe + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set up the test network runtime + uses: ./.github/actions/test-network-setup + + - name: Run Test + working-directory: test-network + run: ../ci/scripts/run-test-network-sbe.sh + env: + CHAINCODE_NAME: ${{ matrix.chaincode-name }} + CHAINCODE_LANGUAGE: ${{ matrix.chaincode-language }} + diff --git a/.github/workflows/test-network-secured.yaml b/.github/workflows/test-network-secured.yaml new file mode 100644 index 00000000..2e487245 --- /dev/null +++ b/.github/workflows/test-network-secured.yaml @@ -0,0 +1,36 @@ +# +# SPDX-License-Identifier: Apache-2.0 +# +name: Test Network Secured +run-name: ${{ github.actor }} is running the Test Network Secured tests + +on: + workflow_dispatch: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + secured: + runs-on: ubuntu-20.04 + strategy: + matrix: + chaincode-language: + - go + chaincode-name: + - secured + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set up the test network runtime + uses: ./.github/actions/test-network-setup + + - name: Run Test + working-directory: test-network + run: ../ci/scripts/run-test-network-secured.sh + env: + CHAINCODE_NAME: ${{ matrix.chaincode-name }} + CHAINCODE_LANGUAGE: ${{ matrix.chaincode-language }} + diff --git a/.github/workflows/test-network.yaml b/.github/workflows/test-network.yaml index cb8cda6c..afaed913 100644 --- a/.github/workflows/test-network.yaml +++ b/.github/workflows/test-network.yaml @@ -1,8 +1,8 @@ # # SPDX-License-Identifier: Apache-2.0 # -name: Test Network -run-name: ${{ github.actor }} is testing the Test Network +name: Test Network Basic +run-name: ${{ github.actor }} is running the Test Network Basic tests on: workflow_dispatch: diff --git a/ci/azure-pipelines.yml b/ci/azure-pipelines.yml index 306d4d57..c486d325 100644 --- a/ci/azure-pipelines.yml +++ b/ci/azure-pipelines.yml @@ -23,94 +23,9 @@ variables: - group: credentials jobs: - - job: REST_Sample displayName: REST Server Sample pool: vmImage: ubuntu-20.04 steps: - template: templates/asset-transfer-basic/azure-pipelines-rest.yml - - - job: TestNetworkLedger - displayName: Test Network - pool: - vmImage: ubuntu-20.04 - strategy: - matrix: - Ledger-Go: - CHAINCODE_NAME: ledger - CHAINCODE_LANGUAGE: go - Ledger-Javascript: - CHAINCODE_NAME: ledger - CHAINCODE_LANGUAGE: javascript - steps: - - template: templates/install-deps.yml - - script: ../ci/scripts/run-test-network-ledger.sh - workingDirectory: test-network - displayName: Run Test Network Ledger Chaincode - - - job: TestNetworkPrivate - displayName: Test Network - pool: - vmImage: ubuntu-20.04 - strategy: - matrix: - Private-Go: - CHAINCODE_NAME: private - CHAINCODE_LANGUAGE: go - steps: - - template: templates/install-deps.yml - - script: ../ci/scripts/run-test-network-private.sh - workingDirectory: test-network - displayName: Run Test Network Private Chaincode - - - job: TestNetworkSBE - displayName: Test Network - pool: - vmImage: ubuntu-20.04 - strategy: - matrix: - SBE-Typescript: - CHAINCODE_NAME: sbe - CHAINCODE_LANGUAGE: typescript - SBE-Java: - CHAINCODE_NAME: sbe - CHAINCODE_LANGUAGE: java - steps: - - template: templates/install-deps.yml - - script: ../ci/scripts/run-test-network-sbe.sh - workingDirectory: test-network - displayName: Run Test Network SBE Chaincode - - - job: TestNetworkSecured - displayName: Test Network - pool: - vmImage: ubuntu-20.04 - strategy: - matrix: - Secured-Go: - CHAINCODE_NAME: secured - CHAINCODE_LANGUAGE: go - steps: - - template: templates/install-deps.yml - - script: ../ci/scripts/run-test-network-secured.sh - workingDirectory: test-network - displayName: Run Test Network Secured Chaincode - - - job: TestNetworkEvents - displayName: Test Network - pool: - vmImage: ubuntu-20.04 - strategy: - matrix: - Events-Javascript: - CHAINCODE_NAME: events - CHAINCODE_LANGUAGE: javascript - Events-Java: - CHAINCODE_NAME: events - CHAINCODE_LANGUAGE: java - steps: - - template: templates/install-deps.yml - - script: ../ci/scripts/run-test-network-events.sh - workingDirectory: test-network - displayName: Run Test Network Events Chaincode diff --git a/ci/templates/asset-transfer-basic/azure-pipelines-rest.yml b/ci/templates/asset-transfer-basic/azure-pipelines-rest.yml index 63868ca4..c6dcdf1a 100644 --- a/ci/templates/asset-transfer-basic/azure-pipelines-rest.yml +++ b/ci/templates/asset-transfer-basic/azure-pipelines-rest.yml @@ -7,19 +7,12 @@ steps: inputs: versionSpec: $(NODE_VER) displayName: Install Node.js - - script: npm install - workingDirectory: asset-transfer-basic/rest-api-typescript - displayName: Install REST Sample Dependencies - - script: npm run build - workingDirectory: asset-transfer-basic/rest-api-typescript - displayName: Build REST Sample Application - - script: npm test - workingDirectory: asset-transfer-basic/rest-api-typescript - displayName: Test REST Sample Application + - script: | docker build -t ghcr.io/hyperledger/fabric-rest-sample . workingDirectory: asset-transfer-basic/rest-api-typescript displayName: Build REST Sample Docker Image + - script: | echo ${GITHUB_PAT} | docker login ghcr.io -u ${GITHUB_USER} --password-stdin docker push ghcr.io/hyperledger/fabric-rest-sample:latest diff --git a/ci/templates/install-deps-hsm.yml b/ci/templates/install-deps-hsm.yml deleted file mode 100644 index f802a3eb..00000000 --- a/ci/templates/install-deps-hsm.yml +++ /dev/null @@ -1,13 +0,0 @@ -# -# SPDX-License-Identifier: Apache-2.0 -# - -steps: - - script: | - sudo apt install -y softhsm2 - displayName: Install SoftHSM - - script: | - echo directories.tokendir = /tmp > $HOME/softhsm2.conf - export SOFTHSM2_CONF=$HOME/softhsm2.conf - softhsm2-util --init-token --slot 0 --label "ForFabric" --pin 98765432 --so-pin 1234 - displayName: Set up SoftHSM \ No newline at end of file diff --git a/ci/templates/install-deps.yml b/ci/templates/install-deps.yml deleted file mode 100644 index 95729378..00000000 --- a/ci/templates/install-deps.yml +++ /dev/null @@ -1,17 +0,0 @@ -# -# SPDX-License-Identifier: Apache-2.0 -# - -steps: - - task: NodeTool@0 - inputs: - versionSpec: $(NODE_VER) - displayName: Install Node.js - - script: curl -L --retry 5 --retry-delay 3 https://hyperledger.jfrog.io/hyperledger/fabric-binaries/hyperledger-fabric-linux-amd64-${FABRIC_VERSION}-stable.tar.gz | tar xz - displayName: Download Fabric CLI - - script: curl -L --retry 5 --retry-delay 3 https://hyperledger.jfrog.io/hyperledger/fabric-binaries/hyperledger-fabric-ca-linux-amd64-${FABRIC_VERSION}-stable.tar.gz | tar xz - displayName: Download Fabric CA CLI - - script: curl https://raw.githubusercontent.com/kadwanev/retry/master/retry -o ./bin/retry && chmod +x ./bin/retry - displayName: Install retry CLI - - script: ./ci/scripts/pullFabricImages.sh - displayName: Pull Fabric Docker Imagess \ No newline at end of file diff --git a/ci/templates/install-k8s-deps.yml b/ci/templates/install-k8s-deps.yml deleted file mode 100644 index 006a2d41..00000000 --- a/ci/templates/install-k8s-deps.yml +++ /dev/null @@ -1,9 +0,0 @@ -# -# SPDX-License-Identifier: Apache-2.0 -# - -steps: - - task: NodeTool@0 - inputs: - versionSpec: $(NODE_VER) - displayName: Install Node.js