Update math/rand import to v2 and refactor random number generation #145
Workflow file for this run
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
name: CI | |
on: | |
pull_request: | |
paths: | |
- "webapp/golang/**" | |
- "webapp/ruby/**" | |
- "webapp/php/**" | |
- "benchmarker/**" | |
- ".github/workflows/ci.yml" | |
- "Makefile" | |
- "webapp/docker-compose.yml" | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build-and-test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Initialize the project | |
run: make init | |
- name: Check for changes in golang directory | |
id: check-changes | |
run: | | |
git fetch origin | |
if git diff --name-only origin/master...${{ github.sha }} | grep 'golang/'; then | |
echo "Changes detected in golang directory" | |
echo "go_changes_detected=true" >> $GITHUB_OUTPUT | |
fi | |
if git diff --name-only origin/master...${{ github.sha }} | grep 'php/'; then | |
echo "Changes detected in php directory" | |
echo "php_changes_detected=true" >> $GITHUB_OUTPUT | |
fi | |
- name: Download purl | |
run: | | |
curl -sL https://github.com/catatsuy/purl/releases/latest/download/purl-linux-amd64.tar.gz | tar xz -C /tmp | |
- name: Move files to /usr/local/bin for purl | |
run: | | |
sudo mv /tmp/purl /usr/local/bin/ | |
- name: Update compose.yml if changes are detected | |
if: steps.check-changes.outputs.go_changes_detected == 'true' | |
run: | | |
purl -fail -overwrite -replace '@context: ruby/@context: golang/@' ./webapp/docker-compose.yml | |
- name: Update compose.yml if changes are detected | |
if: steps.check-changes.outputs.php_changes_detected == 'true' | |
run: | | |
purl -fail -overwrite -replace '@context: (ruby|golang)/@context: php/@' ./webapp/docker-compose.yml | |
mv webapp/etc/nginx/conf.d/default.conf webapp/etc/nginx/conf.d/default.conf.org | |
mv webapp/etc/nginx/conf.d/php.conf.org webapp/etc/nginx/conf.d/php.conf | |
- name: Start the server | |
run: | | |
cd webapp | |
docker compose up --build -d | |
- name: Build the benchmark | |
run: | | |
cd benchmarker | |
docker build -t private-isu-benchmarker . | |
- name: Wait for data initialization to complete | |
run: | | |
cd webapp | |
until docker compose exec -T mysql mysql -uroot -proot -e "SELECT 1 FROM posts LIMIT 1;" isuconp; do | |
echo "Waiting for database initialization..." | |
sleep 10 | |
done | |
until docker compose exec -T mysql mysql -uroot -proot -e "SELECT 1 FROM users LIMIT 1;" isuconp; do | |
echo "Waiting for database initialization..." | |
sleep 10 | |
done | |
until docker compose exec -T mysql mysql -uroot -proot -e "SELECT 1 FROM comments LIMIT 1;" isuconp; do | |
echo "Waiting for database initialization..." | |
sleep 10 | |
done | |
- name: Run the benchmark | |
continue-on-error: true | |
run: | | |
cd benchmarker | |
docker run --network host --add-host host.docker.internal:host-gateway -i private-isu-benchmarker /bin/benchmarker -t http://host.docker.internal -u /opt/userdata | tee benchmark_output.json || echo "BENCHMARK_FAILED=true" >> $GITHUB_ENV | |
- name: Check benchmark result | |
run: | | |
cd benchmarker | |
if [ ! -f benchmark_output.json ]; then | |
echo "benchmark_output.json not found" | |
exit 1 | |
fi | |
if ! jq -e '.pass == true' benchmark_output.json > /dev/null; then | |
echo "BENCHMARK_FAILED=true" >> $GITHUB_ENV | |
exit 1 | |
fi | |
- name: Show logs | |
run: | | |
cd webapp | |
docker compose logs | |
- name: Fail if benchmark failed | |
if: env.BENCHMARK_FAILED == 'true' | |
run: | | |
echo "Benchmark failed" | |
exit 1 |