Skip to content

Update GitHub Actions yml to fix smoke test failure #1865

Update GitHub Actions yml to fix smoke test failure

Update GitHub Actions yml to fix smoke test failure #1865

Workflow file for this run

name: main
on: [pull_request, push]
jobs:
pre-process:
name: Pre process
runs-on: ubuntu-latest
outputs:
were-only-docs-updated: ${{ steps.were-only-docs-updated-action.outputs.were-only-docs-updated }}
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Get commit range
id: get-commit-range-action
uses: ./.github/actions/get-commit-range-action
- name: Were only docs updated
id: were-only-docs-updated-action
uses: ./.github/actions/were-only-docs-updated-action
with:
commit-range: ${{ steps.get-commit-range-action.outputs.commit-range }}
check-header:
name: Check Header
runs-on: ubuntu-latest
needs: pre-process
if: needs.pre-process.outputs.were-only-docs-updated != 'yes'
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Get commit range
id: get-commit-range-action
uses: ./.github/actions/get-commit-range-action
- name: Check header
run: |
git clone --branch=devops https://github.com/vmware/singleton.git devops
cp $GITHUB_WORKSPACE/devops/check_headers.py .
chmod +x check_headers.py
git diff ${{ steps.get-commit-range-action.outputs.commit-range }} --stat
git diff --name-only --diff-filter=d ${{ steps.get-commit-range-action.outputs.commit-range }}
python ./check_headers.py -f "$(git diff --name-only --diff-filter=d ${{ steps.get-commit-range-action.outputs.commit-range }})"
unit-test:
name: Unit Test
runs-on: ubuntu-latest
needs: pre-process
if: needs.pre-process.outputs.were-only-docs-updated != 'yes'
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.16
- name: Unit test
run: |
go build
go test -v | tee unittest.log
if [ x$(tail -n 2 unittest.log | head -1) != xPASS ]; then
echo "exit status 1" && sleep 5s && exit 1
fi
- name: Coverage
run: |
go test -json > report.json
go test -coverprofile=coverage.out
- name: Upload Codecov report for goclient-coverage
uses: codecov/codecov-action@v2
with:
files: ./coverage.out
flags: coverage
security-analysis:
name: Security Analysis
runs-on: ubuntu-latest
needs: pre-process
if: needs.pre-process.outputs.were-only-docs-updated != 'yes'
permissions:
actions: read
contents: read
security-events: write
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.16
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: go
- name: Autobuild
uses: github/codeql-action/autobuild@v1
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
codacy-analysis-cli:
name: Codacy Analysis CLI
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@main
- name: Run Codacy Analysis CLI
uses: codacy/codacy-analysis-cli-action@master
with:
output: results.sarif
format: sarif
# Adjust severity of non-security issues
gh-code-scanning-compat: true
# Force 0 exit code to allow SARIF file generation
# This will handover control about PR rejection to the GitHub side
max-allowed-issues: 2147483647
# Upload the SARIF file generated in the previous step
- name: Upload SARIF results file
uses: github/codeql-action/upload-sarif@main
with:
sarif_file: results.sarif
smoke-test:
name: Smoke Test
runs-on: ubuntu-latest
needs: pre-process
if: needs.pre-process.outputs.were-only-docs-updated != 'yes'
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.17
- name: Set up JDK
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '17'
- name: Smoke Test
run: |
export PATH=${PATH/:\/usr\/local\/lib\/jvm\/openjdk17\/bin:/:}
sudo apt-get update
sudo apt-get install -y openjdk-17-jdk
export JAVA_HOME="/usr/lib/jvm/java-17-openjdk-amd64"
java -version
git clone --branch=master https://github.com/vmware/singleton.git server
git clone --branch=devops https://github.com/vmware/singleton.git devops
cd $GITHUB_WORKSPACE/server/g11n-ws && ./gradlew build -x test
cp $GITHUB_WORKSPACE/devops/deploy/i18n-service/Dockerfile $GITHUB_WORKSPACE/server/publish/
cd $GITHUB_WORKSPACE/server/publish && mv singleton-[0~9]*.jar i18n-service.jar
docker build -t singleton .
docker run -d -p 8090:8090 -p 8091:8091 --name singleton singleton
docker ps
sleep 15s
mkdir -p $GITHUB_WORKSPACE/l10n/bundles
cp -r $GITHUB_WORKSPACE/devops/autotest/client/go/l10n/bundles $GITHUB_WORKSPACE/l10n/
docker cp $GITHUB_WORKSPACE/l10n singleton:/
curl -X GET 'http://localhost:8091/actuator/health'
cd $GITHUB_WORKSPACE/devops/autotest/client/go/goclienttest
echo "" >> go.mod
echo "replace github.com/vmware/singleton => $GITHUB_WORKSPACE" >> go.mod
echo "" >> go.mod
str=$(printf '=%.0s' {1..50})
echo $str Smoke Test Start $str
go mod download github.com/json-iterator/go
go get github.com/json-iterator/[email protected]
go get github.com/smartystreets/goconvey/[email protected]
go mod tidy
go test -v ./...
echo $str Smoke Test End $str