diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 20f5d6b..06c415b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,8 +48,75 @@ jobs: - name: Run tests run: bundle exec rake test - - name: Run dummy app tests - run: bundle exec rake test_dummy + - name: Keep screenshots from failed system tests + uses: actions/upload-artifact@v4 + if: failure() + with: + name: screenshots-${{ matrix.ruby }} + path: ${{ github.workspace }}/test/dummy/tmp/screenshots + if-no-files-found: ignore + + test_generated_app: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + ruby: + - '3.4' + - '3.3' + - '3.2' + gemfile: + - rails_edge + - rails_8_1 + - rails_8_0 + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + bundler-cache: true + + - name: Install Rails + run: | + rails_line=$(grep '"rails"' gemfiles/${{ matrix.gemfile }}.gemfile) + + if echo "$rails_line" | grep -q 'git:'; then + echo "Installing Rails from git" + git_url=$(echo "$rails_line" | sed -E 's/.*git: *"([^"]+)".*/\1/') + branch=$(echo "$rails_line" | sed -E 's/.*branch: *"([^"]+)".*/\1/') + echo "Installing Rails from $git_url (branch: ${branch:-main})" + git clone --depth 1 --branch "${branch:-main}" "$git_url" rails + cd rails + bundle install + bundle exec rake install + else + rails_version=$(echo "$rails_line" | sed -E 's/.*"~> ([0-9.]+)".*/\1/') + echo "Installing Rails $rails_version" + gem install rails -v "$rails_version" + fi + + - name: Create new app and run generator + run: | + rails new test-app --skip-action-mailbox --skip-action-text --skip-active-storage --skip-kamal + cd test-app + bundle install + bundle add webauthn-rails --path .. + rails generate webauthn_authentication --with-rails-authentication + cat <<'RUBY' > config/initializers/webauthn.rb + WebAuthn.configure do |config| + config.allowed_origins = [ "http://localhost:3030" ] + config.rp_name = "WebAuthn Rails Demo App" + end + RUBY + rails generate controller home index + sed 's/# root "posts#index"/root "home#index"/g' config/routes.rb + cat config/routes.rb + bundle exec rake db:migrate + bundle exec rake test - name: Keep screenshots from failed system tests uses: actions/upload-artifact@v4