Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update GitHub Actions workflows #16

Merged
merged 7 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ TODO write docs for staff here

TODO Info here about workflows and links

Most of the linters in `.github/workflows/linters.yml` are powered by [reviewdog](https://github.com/reviewdog/reviewdog).

Run `bundle exec rubocop` to run [Rubocop](https://rubocop.org/). To autocorrect certain errors, run `bundle exec rubocop --autocorrect`.

## Testing

To run tests, run `bundle exec rspec`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: reviewdog
name: Linters
on: [pull_request]
permissions:
contents: read
pull-requests: write
jobs:
pylint:
name: runner / pylint
Expand All @@ -15,6 +18,8 @@ jobs:
# GitHub Status Check won't become failure with warning.
level: warning
glob_pattern: "**/*.py"
filter_mode: nofilter
fail_on_error: true

black:
name: runner / black
Expand All @@ -26,11 +31,13 @@ jobs:
id: action_black
with:
black_args: "."
fail_on_error: true
- name: Annotate diff changes using reviewdog
if: steps.action_black.outputs.is_formatted == 'true'
uses: reviewdog/action-suggester@v1
with:
tool_name: blackfmt
# NOTE: the reviewdog filter_mode is diff_context - this is the only thing supported by GitHub suggestions

markdownlint:
name: runner / markdownlint
Expand All @@ -42,3 +49,24 @@ jobs:
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
reporter: github-pr-check
filter_mode: nofilter
fail_on_error: true

rubocop:
name: runner / rubocop
runs-on: ubuntu-latest
env:
BUNDLE_ONLY: rubocop
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3'
bundler-cache: true
- uses: reviewdog/action-rubocop@v2
with:
reporter: github-pr-check
skip_install: true
use_bundler: true
filter_mode: nofilter
fail_on_error: true
4 changes: 2 additions & 2 deletions .github/workflows/rspec.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Run rspec tests
name: Run all page tests

on: [pull_request]
on: [pull_request, push]

jobs:
build:
Expand Down
2 changes: 2 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
AllCops:
NewCops: enable
17 changes: 11 additions & 6 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
source 'https://rubygems.org'

Check warning on line 1 in Gemfile

View workflow job for this annotation

GitHub Actions / runner / rubocop

[rubocop] reported by reviewdog 🐶 Missing frozen string literal comment. Raw Output: Gemfile:1:1: C: Style/FrozenStringLiteralComment: Missing frozen string literal comment.
gem 'github-pages', group: :jekyll_plugins
gem 'jekyll-sitemap'
gem 'webrick'

group :development, :test do
gem "rspec"
gem "selenium-webdriver"
gem "capybara"
gem "rack-jekyll"
gem "axe-core-rspec"
gem "axe-core-capybara"
gem 'axe-core-capybara'
gem 'axe-core-rspec'
gem 'capybara'
gem 'rack-jekyll'
gem 'rspec'
gem 'selenium-webdriver'
end

group :development, :rubocop do
gem 'rubocop', require: false
gem 'rubocop-rspec', require: false
end
12 changes: 6 additions & 6 deletions spec/accessibility_spec.rb
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
describe "course website", type: :feature, js: true do
describe 'course website', type: :feature, js: true do

Check warning on line 1 in spec/accessibility_spec.rb

View workflow job for this annotation

GitHub Actions / runner / rubocop

[rubocop] reported by reviewdog 🐶 Missing frozen string literal comment. Raw Output: spec/accessibility_spec.rb:1:1: C: Style/FrozenStringLiteralComment: Missing frozen string literal comment.
before :all do
visit('/sitemap.xml')
sitemap_links = page.html.scan(/<loc>.+<\/loc>/)
sitemap_links = page.html.scan(%r{<loc>.+</loc>})
@links = []
sitemap_links.each do |link|
# TODO don't hardcode base url
# TODO: don't hardcode base url
first_removed = link.sub('<loc>https://phrdang.github.io/berkeley-class-site', '')
last_removed = first_removed.sub('</loc>', '')
@links.push(last_removed)
end
end

# TODO run each page's axe check separately so it doesn't exit on first failure
it "is accessible" do
# TODO: run each page's axe check separately so it doesn't exit on first failure
it 'is accessible' do
@links.each do |link|
visit(link)
expect(page).to be_axe_clean.according_to :wcag2a, "path: #{link} not accessible"
end
end
end
end
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file was generated by the `rspec --init` command. Conventionally, all

Check warning on line 1 in spec/spec_helper.rb

View workflow job for this annotation

GitHub Actions / runner / rubocop

[rubocop] reported by reviewdog 🐶 Missing frozen string literal comment. Raw Output: spec/spec_helper.rb:1:1: C: Style/FrozenStringLiteralComment: Missing frozen string literal comment.
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# The generated `.rspec` file contains `--require spec_helper` which will cause
# this file to always be loaded, without a need to explicitly require it in any
Expand Down Expand Up @@ -72,7 +72,7 @@

# https://stackoverflow.com/questions/52506822/testing-a-jekyll-site-with-rspec-and-capybara-getting-a-bizarre-race-case-on-rs
sleep 0.1 while jekyll_app.compiling?

Capybara.app = jekyll_app

# Configure Capybara server (otherwise it will error and say to use webrick or puma)
Expand Down
Loading