From 34734cfff2f3fe6319bfe7aa92cf81733ee2c1fc Mon Sep 17 00:00:00 2001 From: Josh Kneubuhl Date: Fri, 11 Nov 2022 10:56:19 -0500 Subject: [PATCH 1/2] Add FSAT appdev E2E test Signed-off-by: Josh Kneubuhl --- .github/workflows/enable-gha.yaml | 24 -------------- .../workflows/test-fsat-appdev.yaml | 32 +++++++++++-------- full-stack-asset-transfer-guide/README.md | 1 + 3 files changed, 19 insertions(+), 38 deletions(-) delete mode 100644 .github/workflows/enable-gha.yaml rename full-stack-asset-transfer-guide/.github/workflows/test-appdev.yaml => .github/workflows/test-fsat-appdev.yaml (55%) diff --git a/.github/workflows/enable-gha.yaml b/.github/workflows/enable-gha.yaml deleted file mode 100644 index bea0d052..00000000 --- a/.github/workflows/enable-gha.yaml +++ /dev/null @@ -1,24 +0,0 @@ -name: Enable GitHub Actions -run-name: ${{ github.actor }} is activating GitHub Actions on a PR to the main branch 🚀 - -on: - pull_request: - branches: ["main"] - workflow_dispatch: - -jobs: - Explore-GitHub-Actions: - runs-on: ubuntu-latest - steps: - - run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event." - - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!" - - run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." - - name: Check out repository code - uses: actions/checkout@v3 - - run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner." - - run: echo "🖥️ The workflow is now ready to test your code on the runner." - - name: List files in the repository - run: | - ls ${{ github.workspace }} - - run: echo "🍏 This job's status is ${{ job.status }}." - diff --git a/full-stack-asset-transfer-guide/.github/workflows/test-appdev.yaml b/.github/workflows/test-fsat-appdev.yaml similarity index 55% rename from full-stack-asset-transfer-guide/.github/workflows/test-appdev.yaml rename to .github/workflows/test-fsat-appdev.yaml index d0c08e7d..88d225bb 100644 --- a/full-stack-asset-transfer-guide/.github/workflows/test-appdev.yaml +++ b/.github/workflows/test-fsat-appdev.yaml @@ -1,15 +1,23 @@ -name: test-appdev +name: Full Stack AppDev E2E Test +run-name: ${{ github.actor }} is running the FSAT E2E Test 🚀 on: + workflow_dispatch: pull_request: branches: - - main + - "main" + paths: + - "full-stack-asset-transfer-guide/**" jobs: - test-appdev: + test-fsat-appdev: runs-on: ubuntu-latest steps: + - run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event." + - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!" + - run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." + - name: checkout uses: actions/checkout@v3 @@ -32,18 +40,14 @@ jobs: run: | npm install -g @hyperledger-labs/weft - - name: fabric + - name: Install fabric CLI + working-directory: full-stack-asset-transfer-guide run: | curl -sSL https://raw.githubusercontent.com/hyperledger/fabric/main/scripts/install-fabric.sh | bash -s -- binary - - - name: check prereqs - run: | - export WORKSHOP_PATH="${PWD}" - export PATH="${WORKSHOP_PATH}/bin:${PATH}" - export FABRIC_CFG_PATH="${WORKSHOP_PATH}/config" - - ./check.sh + echo ${PWD}/bin >> $GITHUB_PATH - name: just test-appdev - run: | - just test-appdev \ No newline at end of file + working-directory: full-stack-asset-transfer-guide + run: just test-appdev + + - run: echo "🍏 This job's status is ${{ job.status }}." diff --git a/full-stack-asset-transfer-guide/README.md b/full-stack-asset-transfer-guide/README.md index b9e4e04a..dd900ad2 100644 --- a/full-stack-asset-transfer-guide/README.md +++ b/full-stack-asset-transfer-guide/README.md @@ -106,3 +106,4 @@ We'll create a digital representation of these cards on the blockchain ledger. T - [Go Bananas](docs/CloudReady/40-bananas.md) - [Bring it Home](docs/CloudReady/90-teardown.md) + From 8b0dab01b0b44491909bff67889c84b32dd2970a Mon Sep 17 00:00:00 2001 From: Josh Kneubuhl Date: Sun, 13 Nov 2022 04:10:46 -0500 Subject: [PATCH 2/2] Move linters from Azure to GHA Signed-off-by: Josh Kneubuhl --- .github/workflows/lint.yaml | 68 +++++++++++++++++++++ ci/azure-pipelines.yml | 19 ------ ci/scripts/lint-go.sh | 34 +++++++++++ ci/scripts/lint-java.sh | 24 ++++++++ ci/scripts/lint-javascript.sh | 22 +++++++ ci/scripts/{shellcheck.sh => lint-shell.sh} | 0 ci/scripts/lint-typescript.sh | 22 +++++++ ci/scripts/lint.sh | 52 ++-------------- 8 files changed, 176 insertions(+), 65 deletions(-) create mode 100644 .github/workflows/lint.yaml create mode 100755 ci/scripts/lint-go.sh create mode 100755 ci/scripts/lint-java.sh create mode 100755 ci/scripts/lint-javascript.sh rename ci/scripts/{shellcheck.sh => lint-shell.sh} (100%) create mode 100755 ci/scripts/lint-typescript.sh diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml new file mode 100644 index 00000000..2003533d --- /dev/null +++ b/.github/workflows/lint.yaml @@ -0,0 +1,68 @@ +# +# SPDX-License-Identifier: Apache-2.0 +# +name: Lint +run-name: ${{ github.actor }} is linting fabric-samples + +on: + workflow_dispatch: + push: + branches: + - main + - release-1.4 + - release-2.2 + pull_request: + branches: + - main + - release-1.4 + - release-2.2 + +env: + GO_VER: 1.18.3 + NODE_VER: 16.x + JAVA_VER: 11.x + +jobs: + go: + runs-on: ubuntu-latest + steps: + - uses: actions/setup-go@v3 + with: + go-version: ${{ env.GO_VER }} + - uses: actions/checkout@v3 + - run: go install golang.org/x/tools/cmd/goimports@latest + - run: ci/scripts/lint-go.sh + + typescript: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODE_VER }} + - run: ci/scripts/lint-typescript.sh + + javascript: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODE_VER }} + - run: ci/scripts/lint-javascript.sh + + java: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-java@v3 + with: + distribution: temurin + java-version: ${{ env.JAVA_VER }} + - run: ci/scripts/lint-java.sh + + shell: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - run: ci/scripts/lint-shell.sh diff --git a/ci/azure-pipelines.yml b/ci/azure-pipelines.yml index 1fbb352c..0bf9bd8b 100644 --- a/ci/azure-pipelines.yml +++ b/ci/azure-pipelines.yml @@ -86,25 +86,6 @@ jobs: - template: templates/install-deps.yml - template: templates/fabcar/azure-pipelines-typescript.yml - - job: Lint - displayName: Lint - pool: - vmImage: ubuntu-20.04 - steps: - - task: GoTool@0 - inputs: - goBin: $(GO_BIN) - version: $(GO_VER) - displayName: Install GoLang - - task: NodeTool@0 - inputs: - versionSpec: $(NODE_VER) - displayName: Install Node.js - - script: ./ci/scripts/shellcheck.sh - displayName: Lint Shell Scripts - - script: ./ci/scripts/lint.sh - displayName: Lint Code - - job: TestNetworkBasic displayName: Test Network pool: diff --git a/ci/scripts/lint-go.sh b/ci/scripts/lint-go.sh new file mode 100755 index 00000000..e869ef1d --- /dev/null +++ b/ci/scripts/lint-go.sh @@ -0,0 +1,34 @@ +#!/bin/bash +set -euo pipefail + +function print() { + GREEN='\033[0;32m' + NC='\033[0m' + echo + echo -e "${GREEN}${1}${NC}" +} + +dirs=("$(find . -name "*-go" -type d -not -path '*/.*')") +for dir in $dirs; do + print "Linting $dir" + pushd $dir + + print "Running go vet" + go vet -tags pkcs11 ./... + + print "Running gofmt" + output=$(gofmt -l -s $(go list -tags pkcs11 -f '{{.Dir}}' ./...)) + if [[ "${output}" != "" ]]; then + print "The following files contain formatting errors, please run 'gofmt -l -w ' to fix these issues:" + echo "${output}" + fi + + print "Running goimports" + output=$(goimports -l $(go list -tags pkcs11 -f '{{.Dir}}' ./...)) + if [[ "${output}" != "" ]]; then + print "The following files contain import errors, please run 'goimports -l -w ' to fix these issues:" + echo "${output}" + fi + + popd +done \ No newline at end of file diff --git a/ci/scripts/lint-java.sh b/ci/scripts/lint-java.sh new file mode 100755 index 00000000..327a91e7 --- /dev/null +++ b/ci/scripts/lint-java.sh @@ -0,0 +1,24 @@ +#!/bin/bash +set -euo pipefail + +function print() { + GREEN='\033[0;32m' + NC='\033[0m' + echo + echo -e "${GREEN}${1}${NC}" +} + +dirs=("$(find . -name "*-java" -type d -not -path '*/.*')") +for dir in $dirs; do + print "Linting $dir" + pushd $dir + + if [[ -f "pom.xml" ]]; then + print "Running Maven Build" + mvn clean package + else + print "Running Gradle Build" + ./gradlew build + fi + popd +done \ No newline at end of file diff --git a/ci/scripts/lint-javascript.sh b/ci/scripts/lint-javascript.sh new file mode 100755 index 00000000..0279b125 --- /dev/null +++ b/ci/scripts/lint-javascript.sh @@ -0,0 +1,22 @@ +#!/bin/bash +set -euo pipefail + +function print() { + GREEN='\033[0;32m' + NC='\033[0m' + echo + echo -e "${GREEN}${1}${NC}" +} + +dirs=("$(find . -name "*-javascript" -type d -not -path '*/.*')") +for dir in $dirs; do + print "Linting $dir" + pushd $dir + + print "Installing node modules" + npm install + print "Running Lint" + npm run lint + + popd +done \ No newline at end of file diff --git a/ci/scripts/shellcheck.sh b/ci/scripts/lint-shell.sh similarity index 100% rename from ci/scripts/shellcheck.sh rename to ci/scripts/lint-shell.sh diff --git a/ci/scripts/lint-typescript.sh b/ci/scripts/lint-typescript.sh new file mode 100755 index 00000000..86bcc36b --- /dev/null +++ b/ci/scripts/lint-typescript.sh @@ -0,0 +1,22 @@ +#!/bin/bash +set -euo pipefail + +function print() { + GREEN='\033[0;32m' + NC='\033[0m' + echo + echo -e "${GREEN}${1}${NC}" +} + +dirs=("$(find . -name "*-typescript" -type d -not -path '*/.*')") +for dir in $dirs; do + print "Linting $dir" + pushd $dir + + print "Installing node modules" + npm install + print "Running Lint" + npm run lint + + popd +done \ No newline at end of file diff --git a/ci/scripts/lint.sh b/ci/scripts/lint.sh index 74b4f495..842be747 100755 --- a/ci/scripts/lint.sh +++ b/ci/scripts/lint.sh @@ -1,50 +1,10 @@ #!/bin/bash set -euo pipefail -function print() { - GREEN='\033[0;32m' - NC='\033[0m' - echo - echo -e "${GREEN}${1}${NC}" -} +cd "$(dirname "$0")/../.." -go install golang.org/x/tools/cmd/goimports@latest - -dirs=("$(find . -name "*-go" -o -name "*-java" -o -name "*-javascript" -o -name "*-typescript" -not -path '*/.*')") -for dir in $dirs; do - if [[ -d $dir ]] && [[ ! $dir =~ node_modules ]]; then - print "Linting $dir" - pushd $dir - if [[ "$dir" =~ "-go" ]]; then - print "Running go vet" - go vet -tags pkcs11 ./... - print "Running gofmt" - output=$(gofmt -l -s $(go list -tags pkcs11 -f '{{.Dir}}' ./...)) - if [[ "${output}" != "" ]]; then - print "The following files contain formatting errors, please run 'gofmt -l -w ' to fix these issues:" - echo "${output}" - fi - - print "Running goimports" - output=$(goimports -l $(go list -tags pkcs11 -f '{{.Dir}}' ./...)) - if [[ "${output}" != "" ]]; then - print "The following files contain import errors, please run 'goimports -l -w ' to fix these issues:" - echo "${output}" - fi - elif [[ "$dir" =~ "-javascript" || "$dir" =~ "-typescript" ]]; then - print "Installing node modules" - npm install - print "Running Lint" - npm run lint - elif [[ "$dir" =~ "-java" ]]; then - if [[ -f "pom.xml" ]]; then - print "Running Maven Build" - mvn clean package - else - print "Running Gradle Build" - ./gradlew build - fi - fi - popd - fi -done +ci/scripts/lint-go.sh +ci/scripts/lint-javascript.sh +ci/scripts/lint-typescript.sh +ci/scripts/lint-java.sh +ci/scripts/lint-shell.sh \ No newline at end of file