Update dependency puma to v7.0.3 #276
This file contains hidden or 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/go/**" | |
- "webapp/ruby/**" | |
- "webapp/php/**" | |
- "webapp/python/**" | |
- "webapp/nodejs/**" | |
- "bench/**" | |
- "cmd/**" | |
- "initial-data/**" | |
- ".github/workflows/ci.yml" | |
- "Makefile" | |
- "go.mod" | |
- "go.sum" | |
- "compose.yml" | |
- "webapp/compose.yml" | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build-and-test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v5 | |
with: | |
fetch-depth: 0 | |
- name: Initialize the project | |
run: make init | |
- name: Check for changes in webapp directories | |
id: check-changes | |
run: | | |
git fetch origin | |
CHANGED_FILES=$(git diff --name-only origin/${{ github.event.pull_request.base.ref }}...HEAD) | |
if echo "$CHANGED_FILES" | grep 'webapp/ruby/'; then | |
echo "Changes detected in ruby directory" | |
echo "ruby_changes_detected=true" >> $GITHUB_OUTPUT | |
fi | |
if echo "$CHANGED_FILES" | grep 'webapp/php/'; then | |
echo "Changes detected in php directory" | |
echo "php_changes_detected=true" >> $GITHUB_OUTPUT | |
fi | |
if echo "$CHANGED_FILES" | grep 'webapp/python/'; then | |
echo "Changes detected in python directory" | |
echo "python_changes_detected=true" >> $GITHUB_OUTPUT | |
fi | |
if echo "$CHANGED_FILES" | grep 'webapp/nodejs/'; then | |
echo "Changes detected in nodejs directory" | |
echo "nodejs_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 for Ruby if changes are detected | |
if: steps.check-changes.outputs.ruby_changes_detected == 'true' | |
run: | | |
purl -fail -overwrite -replace '@dockerfile: go/@dockerfile: ruby/@' ./webapp/compose.yml | |
- name: Update compose.yml for PHP if changes are detected | |
if: steps.check-changes.outputs.php_changes_detected == 'true' | |
run: | | |
purl -fail -overwrite -replace '@dockerfile: go/@dockerfile: php/@' ./webapp/compose.yml | |
- name: Update compose.yml for Python if changes are detected | |
if: steps.check-changes.outputs.python_changes_detected == 'true' | |
run: | | |
purl -fail -overwrite -replace '@dockerfile: go/@dockerfile: python/@' ./webapp/compose.yml | |
- name: Update compose.yml for Node.js if changes are detected | |
if: steps.check-changes.outputs.nodejs_changes_detected == 'true' | |
run: | | |
purl -fail -overwrite -replace '@dockerfile: go/@dockerfile: nodejs/@' ./webapp/compose.yml | |
- name: Update nginx config for PHP if changes are detected | |
if: steps.check-changes.outputs.php_changes_detected == 'true' | |
run: | | |
cd webapp | |
rm etc/nginx/conf.d/default.conf | |
mv etc/nginx/conf.d/php.conf.org etc/nginx/conf.d/default.conf | |
sudo chmod -R 777 public | |
- name: Start the server | |
run: | | |
cd webapp | |
docker compose up --build -d | |
- name: Build the benchmark | |
run: | | |
docker build -t isucari-benchmarker -f bench/Dockerfile . | |
- name: Wait for data initialization to complete | |
run: | | |
cd webapp | |
until docker compose exec -T mysql mysql -uroot -proot -e "SELECT 1 FROM users LIMIT 1;" isucari; do | |
echo "Waiting for database initialization..." | |
sleep 10 | |
done | |
until docker compose exec -T mysql mysql -uroot -proot -e "SELECT 1 FROM items LIMIT 1;" isucari; do | |
echo "Waiting for database initialization..." | |
sleep 10 | |
done | |
until docker compose exec -T mysql mysql -uroot -proot -e "SELECT 1 FROM transaction_evidences LIMIT 1;" isucari; do | |
echo "Waiting for database initialization..." | |
sleep 10 | |
done | |
until docker compose exec -T mysql mysql -uroot -proot -e "SELECT 1 FROM shippings LIMIT 1;" isucari; do | |
echo "Waiting for database initialization..." | |
sleep 10 | |
done | |
until docker compose exec -T mysql mysql -uroot -proot -e "SELECT 1 FROM categories LIMIT 1;" isucari; do | |
echo "Waiting for database initialization..." | |
sleep 10 | |
done | |
sleep 10 | |
- name: Run the benchmark | |
continue-on-error: true | |
run: | | |
docker container run \ | |
--add-host host.docker.internal:host-gateway \ | |
-p 5678:5678 \ | |
-p 7890:7890 \ | |
-i isucari-benchmarker \ | |
/bin/benchmarker \ | |
-target-url http://host.docker.internal \ | |
-data-dir /initial-data \ | |
-static-dir /static \ | |
-payment-url http://host.docker.internal:5678 \ | |
-payment-port 5678 \ | |
-shipment-url http://host.docker.internal:7890 \ | |
-shipment-port 7890 \ | |
| tee benchmark_output.json || echo "BENCHMARK_FAILED=true" >> $GITHUB_ENV | |
- name: Show logs | |
run: | | |
cd webapp | |
docker compose logs | |
- name: Check benchmark result | |
run: | | |
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: pass is not true" | |
exit 1 | |
fi | |
- name: Fail if benchmark failed | |
if: env.BENCHMARK_FAILED == 'true' | |
run: | | |
echo "Benchmark failed" | |
exit 1 |