Skip to content

Commit

Permalink
Tech improvement: Fix CSS, and enable minification (rstacruz#1472)
Browse files Browse the repository at this point in the history
  • Loading branch information
rstacruz authored Jun 22, 2020
1 parent 81aaaf0 commit 4678708
Show file tree
Hide file tree
Showing 9 changed files with 100 additions and 34 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Build and test CI
on: push

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

# https://github.com/actions/cache/blob/master/examples.md#node---yarn
- name: "Cache: Get yarn cache directory path"
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- name: "Cache: Set up yarn cache"
uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
# https://github.com/actions/cache/blob/master/examples.md#ruby---bundler
- name: "Cache: Set up bundler cache"
uses: actions/cache@v2
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gems-
- name: Use Node.js
uses: actions/setup-node@v1
with: { node-version: '12.x' }

- name: Use Ruby
uses: actions/setup-ruby@v1
with: { ruby-version: '2.7.1' }

- name: Setup dependencies
run: |
yarn --frozen-lockfile
bundle config path vendor/bundle
bundle install --jobs 4 --retry 3
- run: yarn build
- run: yarn test
- run: yarn test:smoke
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ install:
script:
- yarn build
- yarn test
- if ! make test; then make test-warning; exit 16; fi
- yarn test:smoke

cache:
bundler: true
Expand Down
15 changes: 0 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,3 @@ _site:

dev:
yarn dev

test: _site ## Runs rudimentary tests
@test -f _site/vim.html
@test -f _site/react.html
@test -f _site/index.html
@grep "<script src" _site/index.html >/dev/null
@grep "<script src" _site/vim.html >/dev/null
@grep "<script src" _site/react.html >/dev/null

test-warning:
@echo "========="
@echo "If your build failed at this point, it means"
@echo "the site failed to generate. Check the project"
@echo "out locally and try to find out why."
@echo "========="
3 changes: 2 additions & 1 deletion _sass/2017/components/announcements-item.scss
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
}

& > .close::before {
content: "\00D7";
// https://stackoverflow.com/a/30421654
content: unquote("\"")+str-insert("00D7", "\\", 1)+unquote("\"");
font-size: 14px;
}
}
Expand Down
32 changes: 32 additions & 0 deletions _support/smoke_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash
set -eou pipefail

exit_failure() {
echo 'Failed :('
echo ''
echo ' If your build failed at this point, it means'
echo ' the site failed to generate. Check the project'
echo ' out locally and try to find out why.'
}

trap exit_failure ERR


files=(
_site/vim.html
_site/react.html
_site/index.html
)

for fn in "${files[@]}"; do
echo ''
echo -n "→ Checking: $fn... "
test -f "$fn"
grep -q '<script src' "$fn"
grep -q 'assets/packed/app.js' "$fn"
grep -q 'doctype html' "$fn"
grep -q 'link rel="canonical"' "$fn"
done
echo ''
echo ''
echo "✓ Smoke tests good :)"
11 changes: 0 additions & 11 deletions cssnano.config.js

This file was deleted.

13 changes: 13 additions & 0 deletions netlify.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
[build]
command = "yarn build"
publish = "_site/"

# [[plugins]]
# # https://www.npmjs.com/package/netlify-plugin-minify-html
# package = "netlify-plugin-minify-html"
#
# [plugins.inputs]
# contexts = [ 'production', 'branch-deploy', 'deploy-preview' ]
#
# # https://github.com/kangax/html-minifier#options-quick-reference
# [plugins.inputs.minifierOptions]
# removeComments = true
# minifyCSS = true
# minifyJS = true
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"prejekyll:build": "bundle",
"prejekyll:watch": "bundle",
"prettier:format": "prettier --write '_parcel/**/*.{js,scss}'",
"test": "jest"
"test": "jest",
"test:smoke": "bash _support/smoke_test.sh"
}
}
5 changes: 0 additions & 5 deletions postcss.config.js

This file was deleted.

0 comments on commit 4678708

Please sign in to comment.