mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-23 01:55:10 +00:00
Move lint checks from Azure to GHA
Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>
This commit is contained in:
commit
8450e69534
10 changed files with 194 additions and 103 deletions
24
.github/workflows/enable-gha.yaml
vendored
24
.github/workflows/enable-gha.yaml
vendored
|
|
@ -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 }}."
|
|
||||||
|
|
||||||
68
.github/workflows/lint.yaml
vendored
Normal file
68
.github/workflows/lint.yaml
vendored
Normal file
|
|
@ -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
|
||||||
|
|
@ -1,15 +1,23 @@
|
||||||
name: test-appdev
|
name: Full Stack AppDev E2E Test
|
||||||
|
run-name: ${{ github.actor }} is running the FSAT E2E Test 🚀
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- "main"
|
||||||
|
paths:
|
||||||
|
- "full-stack-asset-transfer-guide/**"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test-appdev:
|
test-fsat-appdev:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
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
|
- name: checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
|
@ -32,18 +40,14 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
npm install -g @hyperledger-labs/weft
|
npm install -g @hyperledger-labs/weft
|
||||||
|
|
||||||
- name: fabric
|
- name: Install fabric CLI
|
||||||
|
working-directory: full-stack-asset-transfer-guide
|
||||||
run: |
|
run: |
|
||||||
curl -sSL https://raw.githubusercontent.com/hyperledger/fabric/main/scripts/install-fabric.sh | bash -s -- binary
|
curl -sSL https://raw.githubusercontent.com/hyperledger/fabric/main/scripts/install-fabric.sh | bash -s -- binary
|
||||||
|
echo ${PWD}/bin >> $GITHUB_PATH
|
||||||
- name: check prereqs
|
|
||||||
run: |
|
|
||||||
export WORKSHOP_PATH="${PWD}"
|
|
||||||
export PATH="${WORKSHOP_PATH}/bin:${PATH}"
|
|
||||||
export FABRIC_CFG_PATH="${WORKSHOP_PATH}/config"
|
|
||||||
|
|
||||||
./check.sh
|
|
||||||
|
|
||||||
- name: just test-appdev
|
- name: just test-appdev
|
||||||
run: |
|
working-directory: full-stack-asset-transfer-guide
|
||||||
just test-appdev
|
run: just test-appdev
|
||||||
|
|
||||||
|
- run: echo "🍏 This job's status is ${{ job.status }}."
|
||||||
|
|
@ -87,25 +87,6 @@ jobs:
|
||||||
- template: templates/install-deps.yml
|
- template: templates/install-deps.yml
|
||||||
- template: templates/fabcar/azure-pipelines-typescript.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: KubeTestNetworkBasic
|
- job: KubeTestNetworkBasic
|
||||||
displayName: Kube Test Network
|
displayName: Kube Test Network
|
||||||
pool:
|
pool:
|
||||||
|
|
|
||||||
34
ci/scripts/lint-go.sh
Executable file
34
ci/scripts/lint-go.sh
Executable file
|
|
@ -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 <path>' 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 <path>' to fix these issues:"
|
||||||
|
echo "${output}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
popd
|
||||||
|
done
|
||||||
24
ci/scripts/lint-java.sh
Executable file
24
ci/scripts/lint-java.sh
Executable file
|
|
@ -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
|
||||||
22
ci/scripts/lint-javascript.sh
Executable file
22
ci/scripts/lint-javascript.sh
Executable file
|
|
@ -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
|
||||||
22
ci/scripts/lint-typescript.sh
Executable file
22
ci/scripts/lint-typescript.sh
Executable file
|
|
@ -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
|
||||||
|
|
@ -1,50 +1,10 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
function print() {
|
cd "$(dirname "$0")/../.."
|
||||||
GREEN='\033[0;32m'
|
|
||||||
NC='\033[0m'
|
|
||||||
echo
|
|
||||||
echo -e "${GREEN}${1}${NC}"
|
|
||||||
}
|
|
||||||
|
|
||||||
go install golang.org/x/tools/cmd/goimports@latest
|
ci/scripts/lint-go.sh
|
||||||
|
ci/scripts/lint-javascript.sh
|
||||||
dirs=("$(find . -name "*-go" -o -name "*-java" -o -name "*-javascript" -o -name "*-typescript" -not -path '*/.*')")
|
ci/scripts/lint-typescript.sh
|
||||||
for dir in $dirs; do
|
ci/scripts/lint-java.sh
|
||||||
if [[ -d $dir ]] && [[ ! $dir =~ node_modules ]]; then
|
ci/scripts/lint-shell.sh
|
||||||
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 <path>' 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 <path>' 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
|
|
||||||
Loading…
Reference in a new issue