Skip to content

Commit

Permalink
Update check.yml
Browse files Browse the repository at this point in the history
Signed-off-by: qiaofeng1227 <76487013@qq.com>
  • Loading branch information
qiaofeng1227 authored Oct 22, 2024
1 parent 7cfea0c commit 8085cfd
Showing 1 changed file with 36 additions and 17 deletions.
53 changes: 36 additions & 17 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,49 @@
name: CI

on:
on:
workflow_dispatch:
push:
branches:
- main
- dev
pull_request:
branches:
- main
- dev

jobs:
build:
test-docker-pull:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Pull Docker image with timeout and measure speed
run: |
echo "Pulling Docker image with timeout..."
# Set the maximum time (in seconds) for pulling the image
TIMEOUT_DURATION=5
IMAGE_NAME=docker.rainbond.cc/library/mysql:5.6
# Pull the image with timeout and measure the time
START_TIME=$(date +%s)
timeout $TIMEOUT_DURATION docker pull $IMAGE_NAME 2>&1 | tee pull_output.log || echo "Docker pull timed out or failed"
END_TIME=$(date +%s)
# Calculate the duration
DURATION=$((END_TIME - START_TIME))
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
# Parse the output to find the downloaded size
DOWNLOADED_SIZE=$(grep -oP 'Downloaded \K[0-9]+(?=MB)' pull_output.log | tail -1)
- name: Install dependencies
run: npm install -g yarn && yarn install
# Calculate the average speed (MB/s)
if [ -n "$DOWNLOADED_SIZE" ] && [ "$DURATION" -gt 0 ]; then
AVERAGE_SPEED=$(echo "scale=2; $DOWNLOADED_SIZE / $DURATION" | bc)
echo "Downloaded size: $DOWNLOADED_SIZE MB"
echo "Duration: $DURATION seconds"
echo "Average speed: $AVERAGE_SPEED MB/s"
else
echo "Failed to calculate the average speed."
fi
- name: Run tests
run: npm run start -- --host 0.0.0.0 --port 3000 --locale en
- name: Check Docker images
run: docker images

0 comments on commit 8085cfd

Please sign in to comment.