Skip to content

Commit

Permalink
Using earthly for build
Browse files Browse the repository at this point in the history
  • Loading branch information
adamgordonbell committed Mar 22, 2021
1 parent c9c9dc7 commit e346468
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 66 deletions.
88 changes: 23 additions & 65 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:
jobs:
ci:
if: "!contains(github.event.commits[0].message, '[ci skip]')"
name: 'Ruby ${{ matrix.ruby_version }}'
name: 'Ruby ${{ matrix.ruby_version }} '
runs-on: 'ubuntu-latest'

strategy:
Expand All @@ -23,82 +23,40 @@ jobs:
- 2.5
- 2.7
- 3.0
- jruby-9.2.14.0

- jruby:9.2.14.0
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 5
- name: "Set up Ruby ${{ matrix.ruby_version }}"
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby_version }}
bundler-cache: true
- name: Run Unit Tests
run: bash script/test
env:
CI: true
- name: Run Cucumber Features
run: bash script/cucumber
env:
CI: true
- name: Sanity Check
run: bash script/default-site

style_check:
- uses: actions/checkout@v2
- name: Download released earth
run: "sudo /bin/sh -c 'wget https://github.com/earthly/earthly/releases/download/v0.5.7/earthly-linux-amd64 -O /usr/local/bin/earthly && chmod +x /usr/local/bin/earthly'"
- name: Execute tests
run: earthly --build-arg RUBY=${{ matrix.ruby_version }} +test
profile_docs:
if: "!contains(github.event.commits[0].message, '[ci skip]')"
name: 'Code Style Check (Ruby ${{ matrix.ruby_version }})'
name: 'Profile Docs Site (Ruby ${{ matrix.ruby_version }})'
runs-on: 'ubuntu-latest'
strategy:
fail-fast: false
matrix:
ruby_version:
- 2.5
- 2.4 # Minimum required Ruby version in gemspec
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 5
- name: "Set up Ruby ${{ matrix.ruby_version }}"
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby_version }}
bundler-cache: true
- name: Run RuboCop
run: bash script/fmt

profile_docs:
- uses: actions/checkout@v2
- name: Download released earth
run: "sudo /bin/sh -c 'wget https://github.com/earthly/earthly/releases/download/v0.5.7/earthly-linux-amd64 -O /usr/local/bin/earthly && chmod +x /usr/local/bin/earthly'"
- name: Execute tests
run: earthly --build-arg RUBY=${{ matrix.ruby_version }} +profile-docs
style_check:
if: "!contains(github.event.commits[0].message, '[ci skip]')"
name: 'Profile Docs Site (Ruby ${{ matrix.ruby_version }})'
name: 'Style Check (Ruby ${{ matrix.ruby_version }})'
runs-on: 'ubuntu-latest'
strategy:
fail-fast: false
matrix:
ruby_version:
- 2.4 # Minimum required Ruby version in gemspec
- 2.5
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 5
- name: "Set up Ruby ${{ matrix.ruby_version }}"
uses: actions/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby_version }}
- name: Cache dependencies
uses: actions/cache@v2.1.3
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gems-
- name: 'Update Rubygems and Bundler'
run: |
gem update --system --no-document
gem update bundler --no-document
- name: Set up bundle
run: |
bundle config path vendor/bundle
bundle install --jobs 4 --retry 3
- name: Build Docs site with --profile
run: bash script/profile-docs
- name: Profile memory usage of building Docs site
run: bash script/memprof
- uses: actions/checkout@v2
- name: Download released earth
run: "sudo /bin/sh -c 'wget https://github.com/earthly/earthly/releases/download/v0.5.7/earthly-linux-amd64 -O /usr/local/bin/earthly && chmod +x /usr/local/bin/earthly'"
- name: Execute tests
run: earthly --build-arg RUBY=${{ matrix.ruby_version }} +style-check
49 changes: 49 additions & 0 deletions Earthfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
FROM alpine

# Run locally: `earthly +all` to run full CI process
all:
BUILD --build-arg RUBY=3.0 +test
BUILD --build-arg RUBY=2.7 +test
BUILD --build-arg RUBY=2.5 +test
BUILD --build-arg RUBY=jruby:9.2.14.0 +test
BUILD style-check
BUILD profile-docs

# Run locally: `earthly +test`
# Run with specific version: `earthly --build-arg RUBY=2.5 +test`
test:
FROM +deps
RUN script/test
RUN script/cucumber
RUN script/default-site

style-check:
FROM +deps
RUN script/fmt

profile-docs:
FROM +deps
RUN bundle install --jobs 4
RUN script/profile-docs
RUN script/memprof

# Install dependencies and copy in source
# used in above steps
deps:
ARG RUBY=3.0
IF case $RUBY in jruby*) ;; *) false; esac
FROM $RUBY
ENV JRUBY_OPTS="--dev -J-XX:+TieredCompilation -J-XX:TieredStopAtLevel=1 -J-XX:CompileThreshold=10 -J-XX:ReservedCodeCacheSize=128M"
ELSE
FROM ruby:$RUBY
END
WORKDIR /src
RUN apt-get update && apt-get install nodejs dnsutils git make coreutils g++ build-essential -y
RUN gem install bundler
RUN gem install sassc -v '2.4.0' --source 'https://rubygems.org/'
COPY Gemfile .
COPY jekyll.gemspec .
COPY lib/jekyll/version.rb lib/jekyll/version.rb
COPY test test
RUN bundle install --jobs 4
COPY . .
2 changes: 1 addition & 1 deletion features/post_excerpts.feature
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ Feature: Post excerpts
Then I should get a zero exit status
And I should not see "Kramdown warning" in the build output
But I should see exactly "<p>Install Jekyll</p>" in "_site/just-text-excerpt.html"
And I should see "<p>Alpha <sup id=\"fnref:1\" role=\"doc-noteref\"><a href=\"#fn:1\" class=\"footnote\">1</a></sup></p>" in "_site/text-and-footnote.html"
And I should see "<p>Alpha <sup id=\"fnref:1\" role=\"doc-noteref\"><a href=\"#fn:1\" class=\"footnote\" rel=\"footnote\">1</a></sup></p>" in "_site/text-and-footnote.html"
And I should see "<p>Omega sigma <a href=\"#fnref:1\" class=\"reversefootnote\" role=\"doc-backlink\">&#8617;</a></p>" in "_site/text-and-footnote.html"
And I should see "<p>Read <a href=\"docs.jekyll.com\">docs</a></p>" in "_site/text-and-reference-link.html"
And I should see "<p>Check out <a href=\"jekyllrb.com\">jekyll</a></p>" in "_site/text-and-self-refencing-link.html"

0 comments on commit e346468

Please sign in to comment.