Feature/GitHub actions #47
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: Build and Test with jOOQ and Docker | |
| on: | |
| pull_request: | |
| branches: | |
| - main | |
| push: | |
| branches: | |
| - main | |
| - feature/* | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # リポジトリのチェックアウト | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| # Docker Composeのインストール | |
| - name: Install Docker Compose | |
| run: | | |
| sudo curl -L "https://github.com/docker/compose/releases/download/v2.25.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose | |
| sudo chmod +x /usr/local/bin/docker-compose | |
| # MySQLの起動 | |
| - name: Start MySQL with Docker Compose | |
| run: docker-compose up -d | |
| # MySQLが準備完了するまで待機 | |
| - name: Wait for MySQL to be ready | |
| run: | | |
| timeout 60s bash -c ' | |
| until docker exec $(docker ps -qf "ancestor=mysql:latest") mysqladmin ping -uroot -prootpassword --silent; do | |
| echo "Waiting for MySQL to be ready..." | |
| sleep 5 | |
| done | |
| ' | |
| # MySQLの初期化確認 | |
| - name: Verify MySQL Initialization | |
| run: | | |
| docker exec $(docker ps -qf "ancestor=mysql:latest") mysql -usampleuser -psamplepassword -e "SHOW TABLES;" sampledb | |
| # MySQLログの確認(デバッグ用) | |
| - name: Check MySQL Logs | |
| if: failure() | |
| run: docker-compose logs mysql | |
| # JDKのセットアップ | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@v3 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '21' | |
| # データベース状態の確認 | |
| - name: Check Database State | |
| run: | | |
| docker exec $(docker ps -qf "ancestor=mysql:latest") mysql -usampleuser -psamplepassword -e "SELECT * FROM member;" sampledb | |
| # jOOQクラス生成とビルド | |
| - name: Generate jOOQ Classes and Build | |
| run: ./gradlew clean generateJooq build --info --stacktrace | |
| # テストレポートのアーカイブ | |
| - name: Archive Test Reports | |
| if: always() | |
| uses: actions/upload-artifact@v3 | |
| with: | |
| name: test-reports | |
| path: build/reports/tests/test |