Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
knsh14 committed Jul 14, 2020
0 parents commit bc26fbe
Show file tree
Hide file tree
Showing 74 changed files with 17,229 additions and 0 deletions.
237 changes: 237 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,237 @@
version: 2.1

# -------------------------
# EXECUTORS
# -------------------------
# Re:VIEWのバージョンアップ時はここが変わる or 増える
# ここ以外にCircleCIで考慮しなくていいようにする
executors:
# Executorではジョブ間で再利用するDockerイメージを定義する
# https://circleci.com/docs/2.0/reusing-config/#authoring-reusable-executors
vvakame-executor:
working_directory: ~/review
docker:
- image: vvakame/review:4.1

# -------------------------
# COMMANDS
# -------------------------
commands:
# ジョブ内で実行するステップシーケンスをマップとして定義する。複数のジョブ間でコマンド定義を再利用できる
# https://circleci.com/docs/ja/2.0/configuration-reference/#commandsversion21-%E3%81%8C%E5%BF%85%E9%A0%88
restore_cache_checkout:
steps:
- restore_cache:
key: v1-review-repo-{{ .Environment.CIRCLE_SHA1 }}

save_cache_checkout:
# save_cache_checkoutコマンドは再利用できるようにしていますが実質的にはsetupのタイミングでしか利用しません
steps:
- save_cache:
# working_directoryはsave_cacheには効かないので同じpathになるようにpathsを指定しておく
key: v1-review-repo-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/review

restore_npm_deps:
steps:
- restore_cache:
name: Restore npm dependencies
key: v1-npm-cache-{{ checksum "package-lock.json" }}

save_npm_deps:
steps:
- save_cache:
key: v1-npm-cache-{{ checksum "package-lock.json" }}
paths:
- ./node_modules

restore_npm_deps_subdir:
parameters:
target_dir:
description: ビルド対象ソースがあるディレクトリを指定する
type: string
steps:
- restore_cache:
name: Restore npm dependencies
key: v1-npm-cache-<< parameters.target_dir >>-{{ checksum "<< parameters.target_dir >>/package-lock.json" }}

save_npm_deps_subdir:
parameters:
target_dir:
description: ビルド対象ソースがあるディレクトリを指定する
type: string
steps:
- save_cache:
name: Cache npm dependencies
key: v1-npm-cache-<< parameters.target_dir >>-{{ checksum "<< parameters.target_dir >>/package-lock.json" }}
paths:
- ./<< parameters.target_dir >>/node_modules

# -------------------------
# JOBS
# -------------------------
jobs:
setup:
executor: vvakame-executor
parameters:
target_dir:
description: ビルド対象ソースがあるディレクトリを指定する
type: string
default: ""
steps:
- checkout
- save_cache_checkout
- when:
condition: << parameters.target_dir >>
steps:
- restore_npm_deps_subdir:
target_dir: << parameters.target_dir >>
- run:
name: Initial Setup
command: cd << parameters.target_dir >> && npm install
- save_npm_deps_subdir:
target_dir: << parameters.target_dir >>
- unless:
condition: << parameters.target_dir >>
steps:
- restore_npm_deps
- run:
name: Initial Setup
command: npm install
- save_npm_deps
# ワークスペースの保存(後続のWorkflowsのjobで利用可能)
# https://circleci.com/docs/ja/2.0/configuration-reference/#persist_to_workspace
# rootはWorkspace のルートディレクトリとなるコンテナ内のディレクトリなので=working_directoryが無難
# pathsは相対パス
- persist_to_workspace:
root: ~/review
paths:
- node_modules
- "*/node_modules"

test:
executor: vvakame-executor
parameters:
target_dir:
description: ビルド対象ソースがあるディレクトリを指定する
type: string
default: ""
steps:
- restore_cache_checkout
- attach_workspace:
at: ~/review
- when:
condition: << parameters.target_dir >>
steps:
- run:
name: Test
command: cd << parameters.target_dir >> && npm test
- unless:
condition: << parameters.target_dir >>
steps:
- run:
name: Test
command: npm test

build:
executor: vvakame-executor
parameters:
target_dir:
description: ビルド対象ソースがあるディレクトリを指定する
type: string
default: ""
steps:
- restore_cache_checkout
- attach_workspace:
at: ~/review
- when:
condition: << parameters.target_dir >>
steps:
- run:
name: Build PDF
command: cd << parameters.target_dir >> && npm run pdf
- run:
name: Preparing artifacts
command: |
mkdir -p /tmp/artifacts
cp ./<< parameters.target_dir >>/articles/*.pdf /tmp/artifacts
- unless:
condition: << parameters.target_dir >>
steps:
- run:
name: Build PDF
command: npm run pdf
- run:
name: Preparing artifacts
command: |
mkdir -p /tmp/artifacts
cp ./articles/*.pdf /tmp/artifacts
- store_artifacts:
path: /tmp/artifacts
destination: /

# -------------------------
# WORKFLOWS
# -------------------------
# ここに書いてある順番でCircleCIが動きます。
# Review-Template付属のこの設定は(setup|test|build)それぞれのjobにサブディレクトリが指定できるようになっています
# もしルートに設定ファイルがない場合は次のようにしてください
# jobs:
# - setup:
# target_dir: "subdirectory_name"
# setup以外のtest,buildも同様にtarget_dirを指定してください
workflows:
version: 2
test-and-build:
jobs:
- setup
- test:
requires:
- setup
- build:
requires:
- setup

# ビルド対象が別の場所にあるときのworkflows設定例
# testとbuildはsetupに依存しています
# - setup:
# target_dir: sub_directory_name
# - test:
# target_dir: sub_directory_name
# requires:
# - setup
# - build:
# target_dir: sub_directory_name
# requires:
# - setup

# ビルド対象が2つ以上のworkflows設定例
# リポジトリに2つ以上のRe:VIEWプロジェクトがある場合の指定です。setupも2回以上やる必要があります
# (何度もチェックアウトしてるので気になるならcheckout部分を別jobsにするとよさそう)
#
# ひとつめ(target_dir_a)のsetup,test,build
# - setup:
# name: setup_a
# target_dir: target_dir_a
# - test:
# target_dir: target_dir_a
# requires:
# - setup_a
# - build:
# target_dir: target_dir_a
# requires:
# - setup_a
#
# ふたつめ(target_dir_b)のsetup,test,build
# - setup:
# name: setup_b
# target_dir: target_dir_b
# - test:
# target_dir: target_dir_b
# requires:
# - setup_b
# - build:
# target_dir: target_dir_b
# requires:
# - setup_b
22 changes: 22 additions & 0 deletions .github/workflows/on_push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Build Re:VIEW to make distribution file
# The workflow is triggered on pushes to the repository.
on: [push]

jobs:
build:
name:
runs-on: ubuntu-latest
steps:
# uses v2 Stable version
# https://github.com/actions/checkout
- name: checkout source
uses: actions/checkout@v2
# Build Artifacts
- name: Build distribution file
uses: TechBooster/ReVIEW-build-artifact-action@master
# Upload Distribution file
- name: Upload distribution file to github artifacts
uses: actions/upload-artifact@v2
with:
name: Output documents
path: ./articles/*.pdf
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
node_modules/
Gemfile.lock
*.pdf
.sass-cache/

articles/*.pdf
articles/*.epub
articles/*.html
articles/*.md
articles/*.xml
articles/*.txt
14 changes: 14 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
image: vvakame/review:3.1

build-pdf:
script: # build-in-docker.sh の終盤と同じもの
- ./setup.sh
- npm run pdf
artifacts:
paths:
- articles/ReVIEW-Template.pdf
tags:
- docker

# 文法はこちらを参照してください
# https://docs.gitlab.com/ce/ci/yaml/README.html
3 changes: 3 additions & 0 deletions .gitpod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
image: vvakame/review:3.1
tasks:
- command: ./setup.sh
5 changes: 5 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# A sample Gemfile
source "https://rubygems.org"

gem 'review', '4.1.0'
# gem 'review-peg', '0.2.2'
Loading

0 comments on commit bc26fbe

Please sign in to comment.