From fe2a1868f4b3cfa8f155342ad77b187aa2a2c148 Mon Sep 17 00:00:00 2001 From: naotospace Date: Sat, 15 Feb 2025 08:48:20 +0900 Subject: [PATCH 01/24] add actions --- .github/workflows/ci.yaml | 103 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 .github/workflows/ci.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 00000000..92893120 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,103 @@ +name: CI/CD Pipeline + +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + generate_cache_for_system_test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Restore Docker cache + uses: actions/cache@v4 + with: + path: ~/caches/images.tar + key: docker-${{ hashFiles('.github/workflows/ci.yml', 'docker-compose.system-test.yml', 'Dockerfile.system-test', 'bucky-core.gemspec', '.dockerignore') }} + - name: Build and cache Docker images + run: | + if [ ! -f ~/caches/images.tar ]; then + docker-compose -f docker-compose.system-test.yml build + mkdir -p ~/caches + docker save $(docker images | awk 'NR>=2 && ! /^/{print $1}') -o ~/caches/images.tar + fi + + system_test: + runs-on: ubuntu-latest + needs: generate_cache_for_system_test + strategy: + matrix: + shard: [1, 2] + steps: + - uses: actions/checkout@v4 + - name: Restore Docker cache + uses: actions/cache@v4 + with: + path: ~/caches/images.tar + key: docker-${{ hashFiles('.github/workflows/ci.yml', 'docker-compose.system-test.yml', 'Dockerfile.system-test', 'bucky-core.gemspec', '.dockerignore') }} + - name: Load Docker images + run: docker load -q -i ~/caches/images.tar + - name: Start Docker services + run: docker-compose -f docker-compose.system-test.yml up -d + - name: Run system tests + run: | + find system_testing/testing_code -name "*.bats" | xargs -n 1 -I {} docker exec bucky-core bats "/bucky-core/"{} | tee test-results-${{ matrix.shard }}.log + - name: Stop Docker services + run: docker-compose -f docker-compose.system-test.yml down + - name: Upload test logs + uses: actions/upload-artifact@v4 + with: + name: system-test-logs + path: test-results-*.log + + unit_test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Restore Gem cache + uses: actions/cache@v4 + with: + path: vendor/bundle + key: unit-test-${{ hashFiles('Gemfile.lock') }} + - name: Install dependencies + run: bundle install --path vendor/bundle --quiet + - name: Setup Code Climate test-reporter + run: | + curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter + chmod +x ./cc-test-reporter + - name: Run tests + run: | + ./cc-test-reporter before-build + bundle exec rspec --format html -o rspec-report.html + ./cc-test-reporter after-build --coverage-input-type simplecov --exit-code $? + - name: Upload RSpec HTML report + uses: actions/upload-artifact@v4 + with: + name: rspec-html-report + path: rspec-report.html + - name: Upload coverage report + uses: actions/upload-artifact@v4 + with: + name: simplecov-coverage + path: coverage/ + + static_code_analysis: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Restore Gem cache + uses: actions/cache@v4 + with: + path: vendor/bundle + key: syntax-check-${{ hashFiles('Gemfile.lock') }} + - name: Install dependencies + run: bundle install --path vendor/bundle --quiet + - name: Run RuboCop + run: | + git diff --name-only origin/master...HEAD -- '*.rb' | xargs -r bundle exec rubocop -f html --out report.html + - name: Upload RuboCop report + uses: actions/upload-artifact@v4 \ No newline at end of file From d91b70fc3c6dd4405b83b9a5e2dd93e4b20101f8 Mon Sep 17 00:00:00 2001 From: naotospace Date: Sat, 15 Feb 2025 18:17:27 +0900 Subject: [PATCH 02/24] Fix for testing --- .github/workflows/ci.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 92893120..dd55b338 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -4,9 +4,11 @@ on: push: branches: - master + - migrate_to_gha pull_request: branches: - master + - migrate_to_gha jobs: generate_cache_for_system_test: From 178818f72fb8f138e491030c7f1d5f897b9c47f6 Mon Sep 17 00:00:00 2001 From: naotospace Date: Sat, 15 Feb 2025 18:23:34 +0900 Subject: [PATCH 03/24] update ruby for unit testing --- .github/workflows/ci.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index dd55b338..d018ec4d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -60,6 +60,11 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.2 # 必要なRubyのバージョンを指定 + bundler-cache: true # Gemのキャッシュを自動管理 - name: Restore Gem cache uses: actions/cache@v4 with: @@ -87,6 +92,7 @@ jobs: name: simplecov-coverage path: coverage/ + static_code_analysis: runs-on: ubuntu-latest steps: From f2dda73db21008c96ac618a9419fce1e28f878c6 Mon Sep 17 00:00:00 2001 From: naotospace Date: Sat, 15 Feb 2025 18:27:06 +0900 Subject: [PATCH 04/24] Fix install bundle for unit test --- .github/workflows/ci.yaml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d018ec4d..8330efcf 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -63,15 +63,17 @@ jobs: - name: Set up Ruby uses: ruby/setup-ruby@v1 with: - ruby-version: 3.2 # 必要なRubyのバージョンを指定 - bundler-cache: true # Gemのキャッシュを自動管理 + ruby-version: 3.2 # 必要な Ruby バージョン - name: Restore Gem cache uses: actions/cache@v4 with: path: vendor/bundle key: unit-test-${{ hashFiles('Gemfile.lock') }} - name: Install dependencies - run: bundle install --path vendor/bundle --quiet + run: | + bundle config set --local path 'vendor/bundle' + bundle config set --local without 'development' + bundle install - name: Setup Code Climate test-reporter run: | curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter From dd797ac26337d3eec5ddf79274cddfa4c7b0a616 Mon Sep 17 00:00:00 2001 From: naotospace Date: Sat, 15 Feb 2025 18:29:24 +0900 Subject: [PATCH 05/24] Fix --- .github/workflows/ci.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 8330efcf..6f6a3afa 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -74,6 +74,8 @@ jobs: bundle config set --local path 'vendor/bundle' bundle config set --local without 'development' bundle install + - name: Add bundle bin to PATH + run: echo "$(pwd)/vendor/bundle/bin" >> $GITHUB_PATH - name: Setup Code Climate test-reporter run: | curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter @@ -94,7 +96,6 @@ jobs: name: simplecov-coverage path: coverage/ - static_code_analysis: runs-on: ubuntu-latest steps: From bb53e7972ffb91cbb0356dbacd829a48a6a0e959 Mon Sep 17 00:00:00 2001 From: naotospace Date: Sat, 15 Feb 2025 18:31:44 +0900 Subject: [PATCH 06/24] Check installed gems --- .github/workflows/ci.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 6f6a3afa..ccba04c0 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -74,6 +74,8 @@ jobs: bundle config set --local path 'vendor/bundle' bundle config set --local without 'development' bundle install + bundle list + bundle info rspec - name: Add bundle bin to PATH run: echo "$(pwd)/vendor/bundle/bin" >> $GITHUB_PATH - name: Setup Code Climate test-reporter From 8b46ed2c950a6a2560a4d03e1d86edc814d42b90 Mon Sep 17 00:00:00 2001 From: naotospace Date: Sat, 15 Feb 2025 18:33:14 +0900 Subject: [PATCH 07/24] Fix install environment --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index ccba04c0..0d03ffdf 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -72,7 +72,7 @@ jobs: - name: Install dependencies run: | bundle config set --local path 'vendor/bundle' - bundle config set --local without 'development' + bundle config set --local with 'development' bundle install bundle list bundle info rspec From 934475cf3bbf81ae510afe30739d5a92d5d709ec Mon Sep 17 00:00:00 2001 From: naotospace Date: Sat, 15 Feb 2025 19:30:26 +0900 Subject: [PATCH 08/24] Delete CCQ settings --- .github/workflows/ci.yaml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 0d03ffdf..67d0e3f4 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -78,15 +78,9 @@ jobs: bundle info rspec - name: Add bundle bin to PATH run: echo "$(pwd)/vendor/bundle/bin" >> $GITHUB_PATH - - name: Setup Code Climate test-reporter - run: | - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter - chmod +x ./cc-test-reporter - name: Run tests run: | - ./cc-test-reporter before-build bundle exec rspec --format html -o rspec-report.html - ./cc-test-reporter after-build --coverage-input-type simplecov --exit-code $? - name: Upload RSpec HTML report uses: actions/upload-artifact@v4 with: From 28ba956bd6cc28e086cfe6b3dcb795226e15d7fc Mon Sep 17 00:00:00 2001 From: naotospace Date: Wed, 26 Feb 2025 17:56:23 +0900 Subject: [PATCH 09/24] ci: Add coverage check --- .github/workflows/ci.yaml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 67d0e3f4..a91f2a81 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -74,8 +74,6 @@ jobs: bundle config set --local path 'vendor/bundle' bundle config set --local with 'development' bundle install - bundle list - bundle info rspec - name: Add bundle bin to PATH run: echo "$(pwd)/vendor/bundle/bin" >> $GITHUB_PATH - name: Run tests @@ -91,6 +89,15 @@ jobs: with: name: simplecov-coverage path: coverage/ + - name: Check coverage threshold + env: + COVERAGE_THRESHOLD: 90 + run: | + COVERAGE=$(awk '/lines/ {print $2}' coverage/.last_run.json | tr -d ',') + if (( $(echo "$COVERAGE < $COVERAGE_THRESHOLD" | bc -l) )); then + echo "Test coverage ($COVERAGE%) is below the threshold ($COVERAGE_THRESHOLD%)" + exit 1 + fi static_code_analysis: runs-on: ubuntu-latest From abac3b01ff8d5ac8ae69af5d995ad93da61812d0 Mon Sep 17 00:00:00 2001 From: naotospace Date: Wed, 26 Feb 2025 18:04:50 +0900 Subject: [PATCH 10/24] Fix checking coverage --- .github/workflows/ci.yaml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a91f2a81..fa294f19 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,4 +1,4 @@ -name: CI/CD Pipeline +name: CI Pipeline on: push: @@ -93,7 +93,13 @@ jobs: env: COVERAGE_THRESHOLD: 90 run: | - COVERAGE=$(awk '/lines/ {print $2}' coverage/.last_run.json | tr -d ',') + cat coverage/.last_run.json + COVERAGE=$(jq '.result.covered_percent' coverage/.last_run.json) + if [[ -z "$COVERAGE" || ! "$COVERAGE" =~ ^[0-9]+(\.[0-9]+)?$ ]]; then + echo "Failed to extract coverage percentage." + exit 1 + fi + echo "Coverage: $COVERAGE%" if (( $(echo "$COVERAGE < $COVERAGE_THRESHOLD" | bc -l) )); then echo "Test coverage ($COVERAGE%) is below the threshold ($COVERAGE_THRESHOLD%)" exit 1 From 516072d49dcc33265ad9faa3248fcf2f95ecd35d Mon Sep 17 00:00:00 2001 From: naotospace Date: Wed, 26 Feb 2025 18:06:23 +0900 Subject: [PATCH 11/24] test coverage checking --- .github/workflows/ci.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index fa294f19..23fe287d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -91,9 +91,8 @@ jobs: path: coverage/ - name: Check coverage threshold env: - COVERAGE_THRESHOLD: 90 + COVERAGE_THRESHOLD: 89 run: | - cat coverage/.last_run.json COVERAGE=$(jq '.result.covered_percent' coverage/.last_run.json) if [[ -z "$COVERAGE" || ! "$COVERAGE" =~ ^[0-9]+(\.[0-9]+)?$ ]]; then echo "Failed to extract coverage percentage." From 1e58dfc02c5692dad1b30c4ae9b39ca890339a25 Mon Sep 17 00:00:00 2001 From: naotospace Date: Wed, 26 Feb 2025 18:08:38 +0900 Subject: [PATCH 12/24] test coverage checking --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 23fe287d..9db865b1 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -91,7 +91,7 @@ jobs: path: coverage/ - name: Check coverage threshold env: - COVERAGE_THRESHOLD: 89 + COVERAGE_THRESHOLD: 91 run: | COVERAGE=$(jq '.result.covered_percent' coverage/.last_run.json) if [[ -z "$COVERAGE" || ! "$COVERAGE" =~ ^[0-9]+(\.[0-9]+)?$ ]]; then From f8bb90946f17c390b0792857a0066eeb9952cf9e Mon Sep 17 00:00:00 2001 From: naotospace Date: Wed, 26 Feb 2025 18:09:56 +0900 Subject: [PATCH 13/24] test coverage checking --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 9db865b1..18cf3927 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -91,7 +91,7 @@ jobs: path: coverage/ - name: Check coverage threshold env: - COVERAGE_THRESHOLD: 91 + COVERAGE_THRESHOLD: 90.9 run: | COVERAGE=$(jq '.result.covered_percent' coverage/.last_run.json) if [[ -z "$COVERAGE" || ! "$COVERAGE" =~ ^[0-9]+(\.[0-9]+)?$ ]]; then From 56f03906ab096cbbb720c9eb0f03f3478c2db7c7 Mon Sep 17 00:00:00 2001 From: naotospace Date: Wed, 26 Feb 2025 18:16:10 +0900 Subject: [PATCH 14/24] fix upload artifact --- .github/workflows/ci.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 18cf3927..98c8beef 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -84,11 +84,11 @@ jobs: with: name: rspec-html-report path: rspec-report.html - - name: Upload coverage report + - name: Upload RSpec HTML report uses: actions/upload-artifact@v4 with: - name: simplecov-coverage - path: coverage/ + name: rspec-html-report + path: rspec-report.html - name: Check coverage threshold env: COVERAGE_THRESHOLD: 90.9 From ae5f8a03e63fd65837c16eb6e0ba108f9e8b02c2 Mon Sep 17 00:00:00 2001 From: naotospace Date: Wed, 26 Feb 2025 18:21:41 +0900 Subject: [PATCH 15/24] delete --- .github/workflows/ci.yaml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 98c8beef..f6f63779 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -84,14 +84,9 @@ jobs: with: name: rspec-html-report path: rspec-report.html - - name: Upload RSpec HTML report - uses: actions/upload-artifact@v4 - with: - name: rspec-html-report - path: rspec-report.html - name: Check coverage threshold env: - COVERAGE_THRESHOLD: 90.9 + COVERAGE_THRESHOLD: 90 run: | COVERAGE=$(jq '.result.covered_percent' coverage/.last_run.json) if [[ -z "$COVERAGE" || ! "$COVERAGE" =~ ^[0-9]+(\.[0-9]+)?$ ]]; then From 73d7f623ae3c0f30e0b5cc92b5b113a6bbef7e5c Mon Sep 17 00:00:00 2001 From: naotospace Date: Wed, 26 Feb 2025 18:34:11 +0900 Subject: [PATCH 16/24] devide workflow files --- .github/workflows/ci.yaml | 117 ----------------------------- .github/workflows/lint.yaml | 36 +++++++++ .github/workflows/system_test.yaml | 57 ++++++++++++++ .github/workflows/unit_test.yaml | 55 ++++++++++++++ 4 files changed, 148 insertions(+), 117 deletions(-) delete mode 100644 .github/workflows/ci.yaml create mode 100644 .github/workflows/lint.yaml create mode 100644 .github/workflows/system_test.yaml create mode 100644 .github/workflows/unit_test.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml deleted file mode 100644 index f6f63779..00000000 --- a/.github/workflows/ci.yaml +++ /dev/null @@ -1,117 +0,0 @@ -name: CI Pipeline - -on: - push: - branches: - - master - - migrate_to_gha - pull_request: - branches: - - master - - migrate_to_gha - -jobs: - generate_cache_for_system_test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Restore Docker cache - uses: actions/cache@v4 - with: - path: ~/caches/images.tar - key: docker-${{ hashFiles('.github/workflows/ci.yml', 'docker-compose.system-test.yml', 'Dockerfile.system-test', 'bucky-core.gemspec', '.dockerignore') }} - - name: Build and cache Docker images - run: | - if [ ! -f ~/caches/images.tar ]; then - docker-compose -f docker-compose.system-test.yml build - mkdir -p ~/caches - docker save $(docker images | awk 'NR>=2 && ! /^/{print $1}') -o ~/caches/images.tar - fi - - system_test: - runs-on: ubuntu-latest - needs: generate_cache_for_system_test - strategy: - matrix: - shard: [1, 2] - steps: - - uses: actions/checkout@v4 - - name: Restore Docker cache - uses: actions/cache@v4 - with: - path: ~/caches/images.tar - key: docker-${{ hashFiles('.github/workflows/ci.yml', 'docker-compose.system-test.yml', 'Dockerfile.system-test', 'bucky-core.gemspec', '.dockerignore') }} - - name: Load Docker images - run: docker load -q -i ~/caches/images.tar - - name: Start Docker services - run: docker-compose -f docker-compose.system-test.yml up -d - - name: Run system tests - run: | - find system_testing/testing_code -name "*.bats" | xargs -n 1 -I {} docker exec bucky-core bats "/bucky-core/"{} | tee test-results-${{ matrix.shard }}.log - - name: Stop Docker services - run: docker-compose -f docker-compose.system-test.yml down - - name: Upload test logs - uses: actions/upload-artifact@v4 - with: - name: system-test-logs - path: test-results-*.log - - unit_test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: 3.2 # 必要な Ruby バージョン - - name: Restore Gem cache - uses: actions/cache@v4 - with: - path: vendor/bundle - key: unit-test-${{ hashFiles('Gemfile.lock') }} - - name: Install dependencies - run: | - bundle config set --local path 'vendor/bundle' - bundle config set --local with 'development' - bundle install - - name: Add bundle bin to PATH - run: echo "$(pwd)/vendor/bundle/bin" >> $GITHUB_PATH - - name: Run tests - run: | - bundle exec rspec --format html -o rspec-report.html - - name: Upload RSpec HTML report - uses: actions/upload-artifact@v4 - with: - name: rspec-html-report - path: rspec-report.html - - name: Check coverage threshold - env: - COVERAGE_THRESHOLD: 90 - run: | - COVERAGE=$(jq '.result.covered_percent' coverage/.last_run.json) - if [[ -z "$COVERAGE" || ! "$COVERAGE" =~ ^[0-9]+(\.[0-9]+)?$ ]]; then - echo "Failed to extract coverage percentage." - exit 1 - fi - echo "Coverage: $COVERAGE%" - if (( $(echo "$COVERAGE < $COVERAGE_THRESHOLD" | bc -l) )); then - echo "Test coverage ($COVERAGE%) is below the threshold ($COVERAGE_THRESHOLD%)" - exit 1 - fi - - static_code_analysis: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Restore Gem cache - uses: actions/cache@v4 - with: - path: vendor/bundle - key: syntax-check-${{ hashFiles('Gemfile.lock') }} - - name: Install dependencies - run: bundle install --path vendor/bundle --quiet - - name: Run RuboCop - run: | - git diff --name-only origin/master...HEAD -- '*.rb' | xargs -r bundle exec rubocop -f html --out report.html - - name: Upload RuboCop report - uses: actions/upload-artifact@v4 \ No newline at end of file diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml new file mode 100644 index 00000000..6aefb031 --- /dev/null +++ b/.github/workflows/lint.yaml @@ -0,0 +1,36 @@ +name: Lint + +on: + push: + branches: + - master + - migrate_to_gha + pull_request: + branches: + - master + - migrate_to_gha + +jobs: + run: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.2 # 必要な Ruby バージョン + - name: Restore Gem cache + uses: actions/cache@v4 + with: + path: vendor/bundle + key: lint-${{ hashFiles('Gemfile.lock') }} + - name: Install dependencies + run: | + bundle config set --local path 'vendor/bundle' + bundle config set --local with 'development' + bundle install + - name: Run RuboCop + run: | + git diff --name-only origin/master...HEAD -- '*.rb' | xargs -r bundle exec rubocop -f html --out report.html + - name: Upload RuboCop report + uses: actions/upload-artifact@v4 \ No newline at end of file diff --git a/.github/workflows/system_test.yaml b/.github/workflows/system_test.yaml new file mode 100644 index 00000000..f49976d1 --- /dev/null +++ b/.github/workflows/system_test.yaml @@ -0,0 +1,57 @@ +name: System test + +on: + push: + branches: + - master + - migrate_to_gha + pull_request: + branches: + - master + - migrate_to_gha + +jobs: + generate_cache: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Restore Docker cache + uses: actions/cache@v4 + with: + path: ~/caches/images.tar + key: docker-${{ hashFiles('.github/workflows/ci.yml', 'docker-compose.system-test.yml', 'Dockerfile.system-test', 'bucky-core.gemspec', '.dockerignore') }} + - name: Build and cache Docker images + run: | + if [ ! -f ~/caches/images.tar ]; then + docker-compose -f docker-compose.system-test.yml build + mkdir -p ~/caches + docker save $(docker images | awk 'NR>=2 && ! /^/{print $1}') -o ~/caches/images.tar + fi + + run: + runs-on: ubuntu-latest + needs: generate_cache_for_system_test + strategy: + matrix: + shard: [1, 2] + steps: + - uses: actions/checkout@v4 + - name: Restore Docker cache + uses: actions/cache@v4 + with: + path: ~/caches/images.tar + key: docker-${{ hashFiles('.github/workflows/ci.yml', 'docker-compose.system-test.yml', 'Dockerfile.system-test', 'bucky-core.gemspec', '.dockerignore') }} + - name: Load Docker images + run: docker load -q -i ~/caches/images.tar + - name: Start Docker services + run: docker-compose -f docker-compose.system-test.yml up -d + - name: Run system tests + run: | + find system_testing/testing_code -name "*.bats" | xargs -n 1 -I {} docker exec bucky-core bats "/bucky-core/"{} | tee test-results-${{ matrix.shard }}.log + - name: Stop Docker services + run: docker-compose -f docker-compose.system-test.yml down + - name: Upload test logs + uses: actions/upload-artifact@v4 + with: + name: system-test-logs + path: test-results-*.log \ No newline at end of file diff --git a/.github/workflows/unit_test.yaml b/.github/workflows/unit_test.yaml new file mode 100644 index 00000000..034320de --- /dev/null +++ b/.github/workflows/unit_test.yaml @@ -0,0 +1,55 @@ +name: Unit test + +on: + push: + branches: + - master + - migrate_to_gha + pull_request: + branches: + - master + - migrate_to_gha + +jobs: + run: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.2 # 必要な Ruby バージョン + - name: Restore Gem cache + uses: actions/cache@v4 + with: + path: vendor/bundle + key: unit-test-${{ hashFiles('Gemfile.lock') }} + - name: Install dependencies + run: | + bundle config set --local path 'vendor/bundle' + bundle config set --local with 'development' + bundle install + - name: Add bundle bin to PATH + run: echo "$(pwd)/vendor/bundle/bin" >> $GITHUB_PATH + - name: Run tests + run: | + bundle exec rspec --format html -o rspec-report.html + - name: Upload RSpec HTML report + uses: actions/upload-artifact@v4 + with: + name: rspec-html-report + path: rspec-report.html + - name: Check coverage threshold + env: + COVERAGE_THRESHOLD: 90 + run: | + COVERAGE=$(jq '.result.covered_percent' coverage/.last_run.json) + if [[ -z "$COVERAGE" || ! "$COVERAGE" =~ ^[0-9]+(\.[0-9]+)?$ ]]; then + echo "Failed to extract coverage percentage." + exit 1 + fi + echo "Coverage: $COVERAGE%" + if (( $(echo "$COVERAGE < $COVERAGE_THRESHOLD" | bc -l) )); then + echo "Test coverage ($COVERAGE%) is below the threshold ($COVERAGE_THRESHOLD%)" + exit 1 + fi \ No newline at end of file From 67086f6f726687f5817deb74a133b315c85ac7fd Mon Sep 17 00:00:00 2001 From: naotospace Date: Wed, 26 Feb 2025 18:54:23 +0900 Subject: [PATCH 17/24] fix --- .github/workflows/lint.yaml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 6aefb031..9936a01c 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -31,6 +31,18 @@ jobs: bundle install - name: Run RuboCop run: | - git diff --name-only origin/master...HEAD -- '*.rb' | xargs -r bundle exec rubocop -f html --out report.html + git diff --name-only origin/${{ github.base_ref }}...HEAD -- '*.rb' | xargs -r bundle exec rubocop -f html --out report.html - name: Upload RuboCop report - uses: actions/upload-artifact@v4 \ No newline at end of file + uses: actions/upload-artifact@v4 + + - name: Set up baserepo + run: | + git remote add baserepo git@github.com/"${{ github.repository }}" + echo ${{ github.repository }} + + - name: Fetch upstream branches + run: git fetch baserepo + + - name: Run RuboCop + run: | + git diff --name-only baserepo/${{ github.base_ref }}...HEAD -- '*.rb' | xargs -r bundle exec rubocop -f html --out report.html \ No newline at end of file From 71bf67a3476651223d223118daf6eb747c070d39 Mon Sep 17 00:00:00 2001 From: naotospace Date: Wed, 26 Feb 2025 18:55:41 +0900 Subject: [PATCH 18/24] fix --- .github/workflows/lint.yaml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 9936a01c..87b24062 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -29,20 +29,19 @@ jobs: bundle config set --local path 'vendor/bundle' bundle config set --local with 'development' bundle install - - name: Run RuboCop - run: | - git diff --name-only origin/${{ github.base_ref }}...HEAD -- '*.rb' | xargs -r bundle exec rubocop -f html --out report.html - - name: Upload RuboCop report - uses: actions/upload-artifact@v4 - name: Set up baserepo run: | git remote add baserepo git@github.com/"${{ github.repository }}" echo ${{ github.repository }} + git remote -v - - name: Fetch upstream branches + - name: Fetch baserepo branches run: git fetch baserepo - name: Run RuboCop run: | - git diff --name-only baserepo/${{ github.base_ref }}...HEAD -- '*.rb' | xargs -r bundle exec rubocop -f html --out report.html \ No newline at end of file + git diff --name-only baserepo/${{ github.base_ref }}...HEAD -- '*.rb' | xargs -r bundle exec rubocop -f html --out report.html + + - name: Upload RuboCop report + uses: actions/upload-artifact@v4 From 43f7a804dc57f69187be6b61b03e4b8c7b043a5a Mon Sep 17 00:00:00 2001 From: naotospace Date: Wed, 26 Feb 2025 19:06:06 +0900 Subject: [PATCH 19/24] fix --- .github/workflows/lint.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 87b24062..cf30994b 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -30,18 +30,18 @@ jobs: bundle config set --local with 'development' bundle install - - name: Set up baserepo + - name: Set up forked repository (upstream) + env: + UPSTREAM_REPOSITORY: 'lifull-dev/bucky-core' run: | - git remote add baserepo git@github.com/"${{ github.repository }}" - echo ${{ github.repository }} + git remote add upstream https://github.com/${UPSTREAM_REPOSITORY}.git git remote -v - - - name: Fetch baserepo branches - run: git fetch baserepo + # フォーク元リポジトリをフェッチ + git fetch upstream - name: Run RuboCop run: | - git diff --name-only baserepo/${{ github.base_ref }}...HEAD -- '*.rb' | xargs -r bundle exec rubocop -f html --out report.html + git diff --name-only upstream/${{ github.base_ref }}...HEAD -- '*.rb' | xargs -r bundle exec rubocop -f html --out report.html - name: Upload RuboCop report uses: actions/upload-artifact@v4 From 4e3fc988a304a2decf2568b57268c99a9d6fb511 Mon Sep 17 00:00:00 2001 From: naotospace Date: Wed, 26 Feb 2025 19:59:24 +0900 Subject: [PATCH 20/24] fix --- .github/workflows/lint.yaml | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index cf30994b..6d5f3693 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -1,14 +1,12 @@ name: Lint on: - push: - branches: - - master - - migrate_to_gha pull_request: branches: - master - - migrate_to_gha + - migrate_to_gha # for debug + paths: + - '**/*.rb' jobs: run: @@ -29,14 +27,10 @@ jobs: bundle config set --local path 'vendor/bundle' bundle config set --local with 'development' bundle install - - - name: Set up forked repository (upstream) - env: - UPSTREAM_REPOSITORY: 'lifull-dev/bucky-core' + - name: Set up upstream run: | - git remote add upstream https://github.com/${UPSTREAM_REPOSITORY}.git + git remote add upstream git@github.com/${{ github.event.pull_request.base.repo.full_name }}.git git remote -v - # フォーク元リポジトリをフェッチ git fetch upstream - name: Run RuboCop From 5d197c9cc3374fbdb06edcb8368dc8832bb4808e Mon Sep 17 00:00:00 2001 From: naotospace Date: Wed, 26 Feb 2025 20:03:28 +0900 Subject: [PATCH 21/24] fix: remote url --- .github/workflows/lint.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 6d5f3693..99d7bd2e 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -29,7 +29,7 @@ jobs: bundle install - name: Set up upstream run: | - git remote add upstream git@github.com/${{ github.event.pull_request.base.repo.full_name }}.git + git remote add upstream https://github.com/${{ github.event.pull_request.base.repo.full_name }}.git git remote -v git fetch upstream From ecded47b00b68fe316a2e10ca2b5642d4bbeb72e Mon Sep 17 00:00:00 2001 From: naotospace Date: Wed, 26 Feb 2025 20:13:22 +0900 Subject: [PATCH 22/24] add debug merge-base --- .github/workflows/lint.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 99d7bd2e..15222033 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -35,6 +35,8 @@ jobs: - name: Run RuboCop run: | + echo 'marge-base:' + git merge-base upstream/${{ github.base_ref }} HEAD git diff --name-only upstream/${{ github.base_ref }}...HEAD -- '*.rb' | xargs -r bundle exec rubocop -f html --out report.html - name: Upload RuboCop report From 76de4e6842d586a919eddf607d17ef3e59fd2936 Mon Sep 17 00:00:00 2001 From: naotospace Date: Wed, 26 Feb 2025 20:17:29 +0900 Subject: [PATCH 23/24] fix --- .github/workflows/lint.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 15222033..5f939071 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -32,10 +32,10 @@ jobs: git remote add upstream https://github.com/${{ github.event.pull_request.base.repo.full_name }}.git git remote -v git fetch upstream + git fetch --all - name: Run RuboCop run: | - echo 'marge-base:' git merge-base upstream/${{ github.base_ref }} HEAD git diff --name-only upstream/${{ github.base_ref }}...HEAD -- '*.rb' | xargs -r bundle exec rubocop -f html --out report.html From 33f276823ea41bd533a9cdd39215239ff7b3b15b Mon Sep 17 00:00:00 2001 From: naotospace Date: Wed, 26 Feb 2025 20:29:36 +0900 Subject: [PATCH 24/24] fix --- .github/workflows/lint.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 5f939071..b61b6cbb 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -33,6 +33,7 @@ jobs: git remote -v git fetch upstream git fetch --all + git branch -r - name: Run RuboCop run: |