From cd180e5ebdd9c7a875f2c4cfc1d8330b53a874d3 Mon Sep 17 00:00:00 2001 From: tommy10-code Date: Thu, 11 Sep 2025 20:08:23 +0900 Subject: [PATCH 1/5] CI --- .github/workflows/ci.yml | 86 +++++----------------------------------- 1 file changed, 11 insertions(+), 75 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index df6f052..140dad8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,100 +1,36 @@ name: CI on: - pull_request: push: branches: [ main ] + pull_request: jobs: - scan_ruby: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: ruby/setup-ruby@v1 - with: - ruby-version: .ruby-version - bundler-cache: true - - name: Scan for common Rails security vulnerabilities using static analysis - run: bin/brakeman --no-pager - - lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: ruby/setup-ruby@v1 - with: - ruby-version: .ruby-version - bundler-cache: true - - name: Lint code for consistent style - run: bin/rubocop -f github - - # ← ここをRSpec用に調整 test: runs-on: ubuntu-latest services: - postgres: - image: postgres:17 + db: + image: postgres:15 + ports: [ "5432:5432" ] env: POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres POSTGRES_DB: app_test - ports: - - 5432:5432 - options: >- - --health-cmd="pg_isready -U postgres -d app_test" - --health-interval=10s --health-timeout=5s --health-retries=5 env: RAILS_ENV: test DATABASE_URL: postgres://postgres:postgres@localhost:5432/app_test steps: - # Chrome は system spec 用 - - name: Install system packages - run: sudo apt-get update && sudo apt-get install --no-install-recommends -y google-chrome-stable curl libjemalloc2 libvips postgresql-client - - - uses: actions/checkout@v4 - - - uses: ruby/setup-ruby@v1 + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Ruby + uses: ruby/setup-ruby@v1 with: - ruby-version: .ruby-version + ruby-version: '3.3' bundler-cache: true - - # ★ Node を入れて yarn install(css/jsビルドに必須) - - name: Setup Node - uses: actions/setup-node@v4 - with: - node-version: '20' - cache: 'yarn' - - - name: Install JS deps (if package.json exists) - if: ${{ hashFiles('package.json') != '' }} - run: | - corepack enable - yarn install --frozen-lockfile - - # DB 準備 - name: Prepare DB - run: bundle exec rails db:prepare - - # ★ ここがポイント:RSpec 前に precompile - - name: Precompile assets - run: bundle exec rails assets:precompile - env: - RAILS_ENV: test - - # RSpec を実行(Minitestではなく) + run: bin/rails db:prepare - name: Run RSpec - run: bundle exec rspec --format documentation - - # 失敗時にCapybaraのアーティファクトを保存 - - name: Upload Capybara artifacts - if: failure() - uses: actions/upload-artifact@v4 - with: - name: capybara-artifacts - path: | - tmp/capybara/*.png - tmp/capybara/*.html - if-no-files-found: ignore + run: bundle exec rspec From ba19d1f8e99c5339aa1393d8cccd55c9673f88dd Mon Sep 17 00:00:00 2001 From: tommy10-code Date: Thu, 11 Sep 2025 20:30:07 +0900 Subject: [PATCH 2/5] CI2 --- .github/workflows/ci.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 140dad8..8515875 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,6 +30,23 @@ jobs: with: ruby-version: '3.3' bundler-cache: true + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + cache: 'yarn' # or 'npm' + + - name: Install JS dependencies + run: | + if [ -f yarn.lock ]; then + corepack enable || true + corepack prepare yarn@stable --activate || true + yarn install --frozen-lockfile + elif [ -f package-lock.json ]; then + npm ci + fi + - name: Prepare DB run: bin/rails db:prepare - name: Run RSpec From 564bbff390c83a86ebc832022be1c91f96a93a01 Mon Sep 17 00:00:00 2001 From: tommy10-code Date: Thu, 11 Sep 2025 20:38:38 +0900 Subject: [PATCH 3/5] CI3 --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8515875..9edcc88 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,6 +37,9 @@ jobs: node-version: '20' cache: 'yarn' # or 'npm' + - name: Use Yarn v1 (lockfileに合わせる) + run: corepack prepare yarn@1.22.22 --activate + - name: Install JS dependencies run: | if [ -f yarn.lock ]; then From 98ae57c177b3d2e4c86a131886a9f7354d8c1418 Mon Sep 17 00:00:00 2001 From: tommy10-code Date: Thu, 11 Sep 2025 20:41:05 +0900 Subject: [PATCH 4/5] CI3 --- .github/workflows/ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9edcc88..a3b5028 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,8 +43,6 @@ jobs: - name: Install JS dependencies run: | if [ -f yarn.lock ]; then - corepack enable || true - corepack prepare yarn@stable --activate || true yarn install --frozen-lockfile elif [ -f package-lock.json ]; then npm ci From 40f53d40d45c25d0c34cb7e695d37069b5deb64a Mon Sep 17 00:00:00 2001 From: tommy10-code Date: Thu, 11 Sep 2025 20:55:31 +0900 Subject: [PATCH 5/5] CI4 --- .github/workflows/ci.yml | 4 ++++ app/views/layouts/application.html.erb | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a3b5028..51166cf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,7 +48,11 @@ jobs: npm ci fi + - name: Precompile assets (test) + run: RAILS_ENV=test bin/rails assets:precompile + - name: Prepare DB run: bin/rails db:prepare + - name: Run RSpec run: bundle exec rspec diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 9d269c5..014b790 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -13,7 +13,6 @@ - <%= stylesheet_link_tag "tailwind", "data-turbo-track": "reload" %> <%= stylesheet_link_tag "application", "data-turbo-track": "reload" %> <%= javascript_include_tag "application", "data-turbo-track": "reload", type: "module" %>