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

Configure Travis CI to download Rubygems data for listed gems #46

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
.bundle
.sass-cache
_data/plugins
_data/themes
_site/
*.swp
pkg/
Expand Down
15 changes: 15 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,18 @@ script: script/cibuild
branches:
only:
- master
jobs:
include:
-
if: branch = master AND (type != pull_request OR type != api)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(type != pull_request OR type != api)

wat?
Isn't this condition always true?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was going for commits pushed to master (merge commits from PRs, though I now realize that JekyllBot adds [ci skip] to the merge commits)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I was getting at is that you mean AND rather than OR

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the type: can be either of push, pull_request, api, cron. I felt using OR to be more optimal. But if you feel AND would be better, I'm fine with that..

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(type != pull_request OR type != api)

The OR statement will only evaluate to false if both type != pull_request and type != api are false (because that is what disjunctions are for). How is this possible? What value of type will possibly make both of these statements false?

You may as well replace the whole condition with

 branch = master AND (true)

Copy link
Member

@pathawks pathawks Jul 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think about it this way.

We can use DeMorgan's Law to write the following, logically equivalent statement:

!(type == pull_request AND type == api)

It is not possible for type == pull_request and type == api to both be true for any particular value of type, so the AND will always be false, and !(false) is true.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pathawks I concede. I've fixed the error and replaced the operators with "aliases" to resemble the operators used in Ruby

env: DEPLOY_BUILD=true

deploy:
provider: pages
local-dir: _site
skip-cleanup: true
github-token: $GITHUB_TOKEN # Set in the settings page of your repository, as a secure variable
keep-history: true
on:
repo: jekyll/directory
branch: master
35 changes: 35 additions & 0 deletions _data/plugins.yml → _data/entries.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
plugins:
- grunt-jekyll
- indii-jekyll-flickr
- jekyll_indextank
Expand Down Expand Up @@ -53,3 +54,37 @@
- related_posts-jekyll_plugin
- rust_playground_highlight
- singlepage-jekyll

themes:
- alpha_jekyll_theme
- dimension_jekyll_theme
- editorial_jekyll_theme
- eventually_jekyll_theme
- forty_jekyll_theme
- fractal_jekyll_theme
- future_imperfect_jekyll_theme
- highlights_jekyll_theme
- hyperspace_jekyll_theme
- identity_jekyll_theme
- jekyll-swiss
- jekyll-theme-architect
- jekyll-theme-cayman
- jekyll-theme-dinky
- jekyll-theme-hacker
- jekyll-theme-leap-day
- jekyll-theme-merlot
- jekyll-theme-midnight
- jekyll-theme-minimal
- jekyll-theme-modernist
- jekyll-theme-slate
- jekyll-theme-tactile
- jekyll-theme-time-machine
- lens_jekyll_theme
- material-bliss-jekyll-theme
- minima
- multiverse_jekyll_theme
- phantom_jekyll_theme
- solid_state_jekyll_theme
- spectral_jekyll_theme
- stellar_jekyll_theme
- strata_jekyll_theme
32 changes: 0 additions & 32 deletions _data/themes.yml

This file was deleted.

5 changes: 5 additions & 0 deletions script/cibuild
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@
script/fmt
script/test
script/scan

if [[ -v $DEPLOY_BUILD ]]; then
script/segregate
bundle exec jekyll build
fi
23 changes: 23 additions & 0 deletions script/segregate
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require "open-uri"
require "safe_yaml"

def data_dir(*entries)
File.expand_path(File.join("..", "_data", *entries), __dir__)
end

entries = SafeYAML.load_file(data_dir("entries.yml"))
entries.each do |type, list|
FileUtils.mkdir_p(data_dir(type))
list.each do |item|
begin
data = open("https://rubygems.org/api/v1/gems/#{item}.yaml").read
File.open(data_dir("#{type}/#{item}.yml"), "wb") { |file| file.puts data }
rescue OpenURI::HTTPError
puts "'#{item}' does not seem to exist at rubygems.org"
next
end
end
end