Skip to content

Commit

Permalink
✅ Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
stoe committed Sep 19, 2023
1 parent e75310f commit 7e9a6ad
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 0 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: GitHub Expert Feed CI

on:
pull_request:
branches: ['main']

permissions:
contents: read

concurrency:
# allow only one run per branch and event
group: ci-${{ github.ref }}-${{ github.event_name }}
cancel-in-progress: true

jobs:
ci:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac

- name: Configure Pages
uses: actions/configure-pages@v3

- name: Build Pages
uses: actions/jekyll-build-pages@v1

- name: Setup Ruby
uses: ruby/setup-ruby@5311f05890856149502132d25c4a24985a00d426
with:
bundler-cache: true

- name: Check Cache
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84
with:
path: _site
key: ges-ci-${{ runner.os }}-htmlproofer

- name: Run tests
run: bundle exec rake test
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ source "https://rubygems.org"
gem "jekyll", "~> 3.9.2"
gem 'github-pages', '227', group: :jekyll_plugins
gem 'jekyll-octicons', '17.8.0'

group :test do
gem "rake"
end
28 changes: 28 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env rake
# frozen_string_literal: true

require "json"

task "default" => [:test]
desc "Runs the tests!"

task "test" do
def valid_json?(json)
JSON.parse(json)
true
rescue JSON::ParserError, TypeError => e
false
end

# test if _site/feed.json is valid
File.open("_site/feed.json", "r") do |f|
json = f.read

if valid_json?(json)
puts "feed.json is valid"
else
puts "feed.json is not valid"
exit 1
end
end
end

0 comments on commit 7e9a6ad

Please sign in to comment.