Skip to content

Commit

Permalink
Merge pull request #16 from berkeley-eecs/github-actions
Browse files Browse the repository at this point in the history
Update GitHub Actions workflows
  • Loading branch information
cycomachead authored Jun 18, 2024
2 parents 3cfa91a + 30ef534 commit 82377bb
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 16 deletions.
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
Expand Up @@ -5,10 +5,15 @@ gem 'webrick'
gem 'just-the-docs'

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
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
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

0 comments on commit 82377bb

Please sign in to comment.