-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP - correct run-build.yml file from accidental overwrite
- Loading branch information
1 parent
c177e1e
commit bdc7ecd
Showing
1 changed file
with
63 additions
and
129 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,166 +1,100 @@ | ||
name: Ensure RSpec Tests Pass | ||
|
||
name: Ensure App Builds Successfully | ||
on: | ||
pull_request: | ||
types: [opened, synchronize, reopened] | ||
|
||
jobs: | ||
generate-runtime-log: | ||
# Job 1: Install Gems | ||
install-gems: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Ruby | ||
- name: Set up Ruby and Cache Gems | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
bundler-cache: true | ||
|
||
- name: Install Dependencies | ||
run: bundle install | ||
|
||
- name: Disable Coverage Tools | ||
run: echo "COVERAGE=false" >> $GITHUB_ENV | ||
|
||
- name: List Test Files | ||
run: | | ||
echo "Listing all test files:" | ||
find spec -name '*_spec.rb' || echo "No test files found." | ||
- name: Generate Runtime Log | ||
run: | | ||
mkdir -p tmp | ||
echo "Generating runtime log..." | ||
bundle exec rspec --format ParallelTests::RSpec::RuntimeLogger --out tmp/parallel_runtime_rspec.log --pattern 'spec/**/*_spec.rb' | ||
- name: Debug Runtime Log | ||
run: | | ||
echo "Runtime log contents:" | ||
cat tmp/parallel_runtime_rspec.log || echo "Runtime log is missing or empty." | ||
- name: Verify Runtime Log | ||
run: | | ||
if [ ! -s tmp/parallel_runtime_rspec.log ]; then | ||
echo "Runtime log is empty! Falling back to group-by filesize in subsequent steps." | ||
echo "filesize fallback" > tmp/parallel_runtime_rspec.log | ||
fi | ||
bundler-cache: true # Automatically caches gems based on Gemfile.lock | ||
# Job 2: Install Node Modules | ||
install-node-modules: | ||
runs-on: ubuntu-latest | ||
needs: install-gems | ||
steps: | ||
- name: Restore Workspace | ||
uses: actions/checkout@v3 | ||
|
||
- name: Upload Runtime Log | ||
uses: actions/upload-artifact@v4 | ||
- name: Set up Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
name: parallel-runtime-log | ||
path: tmp/parallel_runtime_rspec.log | ||
node-version-file: '.nvmrc' | ||
cache: 'npm' | ||
|
||
rspec: | ||
needs: generate-runtime-log | ||
strategy: | ||
matrix: | ||
job_index: [0, 1, 2, 3] | ||
runs-on: ubuntu-latest | ||
- name: Install Node Modules | ||
run: npm install | ||
|
||
# Job 3: Precompile Assets | ||
precompile-assets: | ||
runs-on: ubuntu-latest | ||
needs: install-node-modules | ||
steps: | ||
- name: Checkout code | ||
- name: Restore Workspace | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Ruby | ||
uses: ruby/setup-ruby@v1 | ||
- name: Set up Ruby and Node.js | ||
uses: actions/setup-ruby@v1 | ||
with: | ||
bundler-cache: true | ||
|
||
- name: Set Environment Variables | ||
run: | | ||
echo "DATABASE_USERNAME=apache" >> $GITHUB_ENV | ||
echo "DATABASE_PASSWORD=" >> $GITHUB_ENV | ||
echo "COVERALLS_REPO_TOKEN=${{ secrets.COVERALLS_REPO_TOKEN }}" >> $GITHUB_ENV | ||
- name: Download Runtime Log | ||
uses: actions/download-artifact@v4 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
name: parallel-runtime-log | ||
path: tmp | ||
|
||
- name: Pre-create Test Results Directory | ||
run: mkdir -p tmp/test_results | ||
|
||
- name: Run Tests for Job Index ${{ matrix.job_index }} | ||
run: | | ||
if grep -q "filesize fallback" tmp/parallel_runtime_rspec.log; then | ||
echo "Falling back to grouping by filesize..." | ||
TEST_ENV_NUMBER=${{ matrix.job_index }} bundle exec parallel_rspec --group-by filesize --only-group ${{ matrix.job_index }} -- \ | ||
"spec" --format RspecJunitFormatter --out tmp/test_results/result-${{ matrix.job_index }}.xml | ||
else | ||
TEST_ENV_NUMBER=${{ matrix.job_index }} bundle exec parallel_rspec --group-by runtime --only-group ${{ matrix.job_index }} -- \ | ||
"spec" --format RspecJunitFormatter --out tmp/test_results/result-${{ matrix.job_index }}.xml | ||
fi | ||
env: | ||
COVERALLS_PARALLEL: true | ||
|
||
- name: Debug Test Output | ||
run: | | ||
echo "Checking if test output was generated for job index ${{ matrix.job_index }}:" | ||
cat tmp/test_results/result-${{ matrix.job_index }}.xml || echo "No test output found." | ||
node-version-file: '.nvmrc' | ||
cache: 'npm' | ||
|
||
- name: Save Test Results | ||
uses: actions/upload-artifact@v4 | ||
- name: Restore Precompiled Assets Cache | ||
uses: actions/cache@v3 | ||
with: | ||
name: test-results-${{ matrix.job_index }} | ||
path: tmp/test_results/result-${{ matrix.job_index }}.xml | ||
if-no-files-found: warn | ||
path: public/packs-test | ||
key: ${{ runner.os }}-packs-test-${{ hashFiles('app/assets/**/*', 'package-lock.json', 'Gemfile.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-packs-test- | ||
- name: Precompile Assets | ||
run: RAILS_ENV=test bundle exec rails assets:precompile --trace | ||
env: | ||
RAILS_ENV: test | ||
|
||
- name: Save Partial Coverage | ||
uses: actions/upload-artifact@v4 | ||
- name: Save Precompiled Assets Cache | ||
uses: actions/cache@v3 | ||
with: | ||
name: coverage-${{ matrix.job_index }} | ||
path: coverage/lcov/coverage-${{ matrix.job_index }}.info | ||
if-no-files-found: warn | ||
path: public/packs-test | ||
key: ${{ runner.os }}-packs-test-${{ hashFiles('app/assets/**/*', 'package-lock.json', 'Gemfile.lock') }} | ||
|
||
combine-results-and-coverage: | ||
needs: rspec | ||
# Job 4: Run Database Migrations and Verify Initialization | ||
migrations-and-init: | ||
runs-on: ubuntu-latest | ||
|
||
needs: precompile-assets | ||
steps: | ||
- name: Checkout code | ||
- name: Restore Workspace | ||
uses: actions/checkout@v3 | ||
|
||
- name: Download Partial Test Results | ||
uses: actions/download-artifact@v4 | ||
- name: Set up Ruby | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
name: test-results-* | ||
path: tmp/test_results | ||
bundler-cache: true | ||
|
||
- name: Combine Test Results | ||
- name: Set Environment Variables | ||
run: | | ||
mkdir -p coverage | ||
cat tmp/test_results/*.xml > coverage/combined_results.xml | ||
- name: Upload Combined Test Results | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: combined-test-results | ||
path: coverage/combined_results.xml | ||
|
||
- name: Download Partial Coverage Files | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: coverage-* | ||
path: coverage/lcov | ||
|
||
- name: Install LCOV and Coveralls Tools | ||
echo "DATABASE_USERNAME=${{ secrets.DATABASE_USERNAME }}" >> $GITHUB_ENV | ||
echo "DATABASE_PASSWORD=${{ secrets.DATABASE_PASSWORD }}" >> $GITHUB_ENV | ||
- name: Run Database Migrations | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y lcov | ||
gem install coveralls-lcov --user-install | ||
export PATH="$HOME/.gem/ruby/$(ruby -e 'puts RUBY_VERSION')/bin:$PATH" | ||
RAILS_ENV=test bundle exec rails db:migrate | ||
env: | ||
DATABASE_USERNAME: ${{ secrets.DATABASE_USERNAME }} | ||
DATABASE_PASSWORD: ${{ secrets.DATABASE_PASSWORD }} | ||
RAILS_ENV: test | ||
|
||
- name: Combine Coverage Files | ||
- name: Verify App Initialization | ||
run: | | ||
lcov --add-tracefile=coverage/lcov/coverage-0.info \ | ||
--add-tracefile=coverage/lcov/coverage-1.info \ | ||
--add-tracefile=coverage/lcov/coverage-2.info \ | ||
--add-tracefile=coverage/lcov/coverage-3.info \ | ||
--output-file=coverage/lcov/combined.info | ||
- name: Upload Combined Coverage to Coveralls | ||
run: coveralls-lcov -v -n coverage/lcov/combined.info | ||
RAILS_ENV=test bundle exec rails runner "puts 'App initialized successfully'" | ||
env: | ||
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} | ||
DATABASE_USERNAME: ${{ secrets.DATABASE_USERNAME }} | ||
DATABASE_PASSWORD: ${{ secrets.DATABASE_PASSWORD }} | ||
RAILS_ENV: test |