Skip to content

Commit 3dfb021

Browse files
committed
create linter artifact
1 parent 7073444 commit 3dfb021

File tree

2 files changed

+36
-4
lines changed

2 files changed

+36
-4
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ jobs:
3131
name: Lint
3232
runs-on: ubuntu-24.04
3333
steps:
34+
- name: Set start time
35+
run: echo "START_TIME=$(date +"%Y-%m-%dT%H:%M:%S.%NZ")" >> ${GITHUB_ENV}
3436
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
3537
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
3638
with:
@@ -39,7 +41,7 @@ jobs:
3941
uses: golangci/golangci-lint-action@82d40c283aeb1f2b6595839195e95c2d6a49081b # v5.0.0
4042
with:
4143
version: "${{ env.GOLANGCI_LINT_VERSION }}"
42-
args: -c ./scripts/.golangci.yml --output.json.path > test_results/lint-results.json
44+
args: -c ./scripts/.golangci.yml --out-format=json > lint-output.json
4345
skip-cache: true
4446
- name: Lint SDK Code
4547
uses: golangci/golangci-lint-action@82d40c283aeb1f2b6595839195e95c2d6a49081b # v5.0.0
@@ -48,12 +50,15 @@ jobs:
4850
working-directory: sdk
4951
args: -c ../scripts/.golangci.yml
5052
skip-cache: true
51-
- name: Upload artifact
53+
- name: Set Linting Outputs
54+
if: success() || failure()
55+
run: bash ./scripts/format_workflow_outputs.sh ${{ job.status }} ${{ env.START_TIME }}
56+
- name: Upload Artifact
5257
if: success() || failure()
5358
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808
5459
with:
55-
name: linting-test-results
56-
path: test_results/lint-results.json
60+
name: lint-results
61+
path: lint-results.json
5762
retention-days: 1
5863

5964
unit-test:
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
LINT_FILE="lint-output.json"
2+
START_TIME="$2"
3+
END_TIME="`date "+%Y-%m-%dT%H:%M:%S.%NZ"`"
4+
START_SECONDS=$(date -d "$START_TIME" +%s.%N)
5+
END_SECONDS=$(date -d "$END_TIME" +%s.%N)
6+
DURATION=$(echo "$END_SECONDS - $START_SECONDS" | bc)
7+
MSG=""
8+
9+
if [ "$1" == "success" ]; then
10+
RESULT="pass"
11+
elif [ "$1" == "failure" ]; then
12+
RESULT="fail"
13+
else
14+
RESULT="skip"
15+
fi
16+
17+
if [[ -f "$LINT_FILE" ]]; then
18+
NUM_ISSUES=$(jq '.Issues | length' "$LINT_FILE")
19+
echo "$NUM_ISSUES"
20+
21+
if [[ "$NUM_ISSUES" -ge 1 ]]; then
22+
MSG="`jq -r '.Issues[0].Text' "$LINT_FILE"`"
23+
echo
24+
fi
25+
fi
26+
27+
echo "{\"start_at\": \"$START_TIME\", \"end_at\": \"$END_TIME\", \"duration_seconds\": \"$DURATION\", \"result\": \"$RESULT\", \"msg\": \"$MSG\"}" > lint-result.json

0 commit comments

Comments
 (0)