-
Notifications
You must be signed in to change notification settings - Fork 988
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CI: coverage report for integration test (#5425)
- Loading branch information
1 parent
8fbbb9f
commit c022f41
Showing
7 changed files
with
151 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
name: 'mount_coverage_dir' | ||
description: 'mount coverage directory' | ||
inputs: | ||
mount_point: | ||
description: 'mount point' | ||
required: true | ||
type: string | ||
subdir: | ||
description: 'subdir' | ||
required: false | ||
type: string | ||
token: | ||
description: 'token of jfs' | ||
required: true | ||
type: string | ||
access_key: | ||
description: 'access key of object storage service' | ||
required: true | ||
type: string | ||
secret_key: | ||
description: 'secret key of object storage service' | ||
required: true | ||
type: string | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: set subdir | ||
shell: bash | ||
env: | ||
GH_TOKEN: ${{ github.token }} | ||
run: | | ||
jobs=$(gh api repos/${{ github.repository }}/actions/runs/${{ github.run_id}}/attempts/${{ github.run_attempt }}/jobs) | ||
job_id=$(echo $jobs | jq -r '.jobs[] | select(.runner_name=="${{ runner.name }}") | select(.status=="in_progress") | .id') | ||
echo Job ID is: ${job_id} | ||
if [ "${{ github.event_name }}" == "pull_request" ]; then | ||
branch=${GITHUB_BASE_REF} # 目标分支 | ||
elif [ "${{ github.event_name }}" == "push" ]; then | ||
branch=${GITHUB_REF#refs/heads/} # 当前分支 | ||
else | ||
branch=${GITHUB_REF#refs/heads/} # 对于 schedule 和 workflow_dispatch | ||
fi | ||
echo input.subdir is ${{inputs.subdir}} | ||
if [ -z "${{inputs.subdir}}" ]; then | ||
if [[ "${{github.event_name}}" == "schedule" ]]; then | ||
subdir=juicefs/schedule/$(date +"%Y%m%d")/${{github.workflow}} | ||
else | ||
subdir=juicefs/pr/$branch/${{github.workflow}}/${job_id} | ||
fi | ||
else | ||
subdir=${{inputs.subdir}} | ||
fi | ||
echo "subdir=$subdir" | ||
echo "subdir=$subdir" >> $GITHUB_ENV | ||
- name: mount coverage dir | ||
shell: bash | ||
run: | | ||
sudo mkdir -p /root/.juicefs | ||
sudo wget -q s.juicefs.com/static/Linux/mount -O /root/.juicefs/jfsmount | ||
sudo chmod +x /root/.juicefs/jfsmount | ||
sudo curl -s -L https://juicefs.com/static/juicefs -o /usr/local/bin/juicefs && sudo chmod +x /usr/local/bin/juicefs | ||
sudo juicefs auth ci-coverage --access-key ${{ inputs.access_key }} --secret-key ${{ inputs.secret_key }} --token ${{inputs.token}} --encrypt-keys | ||
sudo juicefs mount ci-coverage --subdir ${subdir} ${{inputs.mount_point}} --allow-other | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: 'upload_coverage_report' | ||
description: 'upload coverage report to oss' | ||
inputs: | ||
type: | ||
description: 'type of the test' | ||
required: true | ||
default: 'integration' | ||
type: string | ||
|
||
UPLOAD_TOKEN: | ||
description: 'upload token' | ||
required: true | ||
type: string | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: umount juicefs | ||
shell: bash | ||
run: | | ||
sudo umount /tmp/jfs || true | ||
sleep 3s | ||
- name: generate mount coverage report | ||
shell: bash | ||
run: | | ||
echo "generate coverage percentage report" | ||
sudo go tool covdata percent -i=cover/ | sudo tee cover/percent.txt | ||
echo "generate coverage text report" | ||
sudo go tool covdata textfmt -i=cover/ -o cover/cover.txt | ||
echo "generate coverage html report" | ||
sudo go tool cover -html=cover/cover.txt -o cover/cover.html | ||
.github/scripts/upload_coverage_report.sh cover/cover.html juicefs_${{github.workflow}}_${{github.run_id}}.html ${{inputs.UPLOAD_TOKEN}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/bash | ||
|
||
# 参数检查 | ||
if [ "$#" -ne 3 ]; then | ||
echo "Usage: $0 <coverage_file> <upload_path> <token>" | ||
exit 1 | ||
fi | ||
|
||
COVERAGE_FILE=$1 | ||
UPLOAD_PATH=$2 | ||
TOKEN=$3 | ||
attempt=1 | ||
max_attempts=3 | ||
|
||
while [ $attempt -le $max_attempts ]; do | ||
response=$(curl -w '%{http_code}' -s -o /dev/null --form "file=@${COVERAGE_FILE}" "https://juicefs.com/upload-file-u80sdvuke/${UPLOAD_PATH}?token=${TOKEN}") | ||
if [ "$response" -eq 200 ]; then | ||
echo "Coverage Report: https://i.juicefs.io/ci-coverage/${UPLOAD_PATH}" | ||
break | ||
else | ||
echo "Upload attempt $attempt failed with status code $response. Retrying..." | ||
attempt=$((attempt + 1)) | ||
sleep 5 # 等待5秒钟后重试 | ||
fi | ||
done | ||
|
||
if [ "$response" -ne 200 ]; then | ||
echo "Upload failed after $max_attempts attempts with status code $response" | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters