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

Chore/wireframe preview ci #2026

Merged
merged 12 commits into from
Jul 20, 2021
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
30 changes: 0 additions & 30 deletions .github/workflows/gh-pages-deploy.yml

This file was deleted.

70 changes: 32 additions & 38 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,64 +5,58 @@ name: Deploy-preview
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
branches:
- '*'
- '!master'
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
env:
BUNDLE_WITH: test jekyll_plugins

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
# store branch name in ${BRANCH_NAME}
- uses: nelonoel/branch-name@v1.0.1
push:
branches:
- '**'
- '!main'

jobs: # A workflow run is made up of one or more jobs that can run sequentially or in parallel
build: # This workflow contains a single job called "build"
runs-on: ubuntu-latest # The type of runner that the job will run on
env:
BUNDLE_WITH: test jekyll_plugins
SITE_ID: 'api' # which iiif site this is
steps: # Steps represent a sequence of tasks that will be executed as part of the job
- name: Checkout # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
uses: actions/checkout@v2
- name: Export BRANCH_NAME # store branch name in ${BRANCH_NAME}
uses: nelonoel/branch-name@v1.0.1
- name: Setup ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true

#- name: install
# run: gem install bundler && bundle

# - name: Test site
# run: bundle exec rake ci
- name: Set api Root
run: sed -i "s/^api_url:.*$/api_url:\t'\/api\/${{ env.BRANCH_NAME}}\/api'/g" _config.yml

# Build jekyll site
- name: Build Jekyll
run: bundle exec jekyll clean && bundle exec jekyll build --baseurl /api/${{ env.BRANCH_NAME}}

# Deploy to Preview site
- name: Create GitHub deployment
- name: Install
run: gem install bundler && bundle
- name: Build preview site
run: bundle exec rake build:preview
- name: Test html
run: bundle exec rake test:html
- name: Test internal links
run: bundle exec rake test:links:internal
- name: Test *iiif.io* links
run: bundle exec rake test:links:iiif
- name: Test external links
run: bundle exec rake test:links:external
- name: Spec tests
run: bundle exec rake test:spec
- name: Create GitHub deployment # Deploy to Preview site
uses: glenrobson/deployments@v0.4.2
id: deployment
with:
step: start
token: ${{ secrets.GITHUB_TOKEN }}
auto_inactive: 'false'
env: staging

- name: Deploy to S3
uses: glenrobson/s3-sync-action@v0.5.1
with:
args: --acl public-read
args: --acl public-read
env:
AWS_S3_BUCKET: "preview.iiif.io"
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
SOURCE_DIR: "_site"
DEST_DIR: "api/${BRANCH_NAME}"
- name: Update deployment status
uses: glenrobson/deployments@v0.4.2
if: always()
Expand All @@ -72,4 +66,4 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
env_url: "https://preview.iiif.io/api/${{ env.BRANCH_NAME}}/api/index.html"
env_url: "https://preview.iiif.io/${{ env.SITE_ID }}/${{ env.BRANCH_NAME }}/index.html"
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
GIT
remote: https://github.com/mnyrop/iiifc-theme.git
revision: 67f937a18608494d2f8c81ab5b55c8b9315299d4
revision: 39512fb2bf0217df3ce18404879b940fb89511ee
branch: main
specs:
iiifc-theme (0.1.0)
Expand Down
124 changes: 97 additions & 27 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,41 +1,111 @@
require 'fileutils'
require 'html-proofer'
require 'rspec/core/rake_task'

RSpec::Core::RakeTask.new(:spec)
require 'yaml'

SITE_DIR = './_site'
CONFIG = YAML.load_file '_config.yml'
SITE_ID = ENV['SITE_ID'] || CONFIG.fetch('site_id', 'root')

def jekyll(cmd)
sh "bundle exec jekyll #{cmd}"
end
# configure default task
task default: :ci

def build_site
jekyll 'clean'
jekyll "build -d _site/test --baseurl /test"
desc 'Run the site locally on localhost:4000'
task :dev do
sh 'bundle exec jekyll clean'
sh 'bundle exec jekyll serve --watch --drafts'
end

desc 'Run the Markdown specs and HTML Proofer'
desc 'Build CI site, run html-proofer and spec tests'
task :ci do
build_site
#sh 'scripts/check_json.py -v'
Rake::Task['spec'].invoke
Rake::Task['check_html'].invoke
Rake::Task['build:ci'].invoke
Rake::Task['test:all'].invoke
end

desc 'Check all links and cache the results'
task :check_html do
HTMLProofer.check_directory(SITE_DIR, check_html: true,
validation: {report_mismatched_tags:true, report_invalid_tags: true },
disable_external: true,
checks_to_ignore: ['LinkCheck']
).run
end
namespace :build do
def build(dest=nil, baseurl=nil)
sh "bundle exec jekyll clean"
cmd = "bundle exec jekyll build"
cmd += " -d '#{dest}'" unless dest.nil?
cmd += " --baseurl '#{baseurl}'" unless baseurl.nil?
sh cmd
end

desc 'Run the site locally on localhost:4000'
task :dev do
sh 'bundle exec jekyll clean'
sh 'bundle exec jekyll build'
sh 'bundle exec jekyll serve --watch --drafts'
desc 'Clean and build with branch preview URL overrides'
task :preview do
branch = `git rev-parse --abbrev-ref HEAD`.strip
baseurl = "/#{SITE_ID}/#{branch}"
dest = SITE_DIR + baseurl

build dest=dest, baseurl=baseurl
end

desc 'Clean and build with CI test overrides'
task :ci do
baseurl = '/test/extra-test'
dest = SITE_DIR + baseurl

build dest=dest, baseurl=baseurl
end
end

task default: :ci
namespace :test do
RSpec::Core::RakeTask.new :spec

task :all do
Rake::Task['test:html'].invoke
Rake::Task['test:links:internal'].invoke
Rake::Task['test:links:iiif'].invoke
# Rake::Task['test:links:external'].invoke
Rake::Task['test:spec'].invoke
end

desc 'Check html'
task :html do
opts = {
check_html: true,
assume_extension: true,
validation: {
report_mismatched_tags: true,
report_invalid_tags: true
},
checks_to_ignore: ['LinkCheck']
}
HTMLProofer.check_directory(SITE_DIR, opts).run
end

namespace :links do
desc 'Check for internal link errors'
task :internal do
puts 'Checking for internal link errors'
opts = {
checks_to_ignore: ['ImageCheck', 'HtmlCheck', 'ScriptCheck'],
disable_external: true,
internal_domains: ['localhost:4000']
}
HTMLProofer.check_directory(SITE_DIR, opts).run
end

desc 'Check for *iiif.io* link errors'
task :iiif do
puts 'Checking for link errors in *iiif.io* sites'
opts = {
checks_to_ignore: ['ImageCheck', 'HtmlCheck', 'ScriptCheck'],
url_ignore: [/^((?!iiif\.io).)*$/, 'github'] # temporarily ignore iiif.io github repo errors
}
HTMLProofer.check_directory(SITE_DIR, opts).run
end

desc 'Check for external link rot'
task :external do
puts 'Checking for external link errors'
opts = {
external_only: true,
enforce_https: true,
checks_to_ignore: ['ImageCheck', 'HtmlCheck', 'ScriptCheck'],
url_ignore: [/.*iiif\.io.*/]
}
HTMLProofer.check_directory(SITE_DIR, opts).run
end
end
end
7 changes: 4 additions & 3 deletions _config.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
site_id: api
theme: iiifc-theme
source: source
permalink: pretty
baseurl: '/api'

api_url: ''
root_url: 'https://preview.iiif.io/root/wireframe'
cookbook_url: 'https://preview.iiif.io/cookbook/wireframe/'
api_url: '/api'
cookbook_url: 'https://iiif.io/api/cookbook/'

plugins:
- jekyll-data
- jekyll-gzip
- jekyll-redirect-from
- jekyll-liquify
- jekyll-redirect-from

notification:
enabled: true
Expand Down
20 changes: 0 additions & 20 deletions _ghpages_config.yml

This file was deleted.

6 changes: 3 additions & 3 deletions invalid_content_to_save/annotations.md
Original file line number Diff line number Diff line change
Expand Up @@ -450,9 +450,9 @@ Many thanks to the members of the [IIIF][iiif-community] for their continuous en
[paging]: #paging-properties
[resource-structure]: #resource-structure

[icon-req]: /img/metadata-api/required.png "Required"
[icon-recc]: /img/metadata-api/recommended.png "Recommended"
[icon-req]: {{ site.api_url }}/assets/images/icons/required.png "Required"
[icon-recc]: {{ site.api_url }}/assets/images/icons/recommended.png "Recommended"
[icon-opt]: /img/metadata-api/optional.png "Optional"
[icon-na]: /img/metadata-api/not_allowed.png "Not allowed"
[icon-na]: {{ site.api_url }}/assets/images/icons/not_allowed.png "Not allowed"

{% include acronyms.md %}
Loading