From b71ad2d01404ec9d8cf12979cca37d47310e9aa7 Mon Sep 17 00:00:00 2001 From: Shohei Ueda <30958501+peaceiris@users.noreply.github.com> Date: Fri, 27 Mar 2020 19:07:48 +0900 Subject: [PATCH] ci: Add workflow for developing container (#231) * ci: Add workflow for developing container * ci: Add CI tasks to Makefile * chore: Add RUNNER_TEMP to Dockerfile * deps: Bump git from 2.25.0 to 2.26.0 --- .github/workflows/dev-image.yml | 37 +++++++++++++++++++++++++++++++++ Dockerfile | 3 ++- Makefile | 15 ++++++++++--- package.json | 4 ++-- 4 files changed, 53 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/dev-image.yml diff --git a/.github/workflows/dev-image.yml b/.github/workflows/dev-image.yml new file mode 100644 index 0000000..2a27412 --- /dev/null +++ b/.github/workflows/dev-image.yml @@ -0,0 +1,37 @@ +name: 'Dev Image CI' + +on: + push: + branches: + - master + paths: + - '.github/workflows/dev-image.yml' + - '.dockerignore' + - '.nvmrc' + - 'Dockerfile' + - 'Makefile' + pull_request: + types: + - opened + - synchronize + paths: + - '.github/workflows/dev-image.yml' + - '.dockerignore' + - '.nvmrc' + - 'Dockerfile' + - 'Makefile' + +jobs: + skipci: + runs-on: ubuntu-18.04 + steps: + - run: echo "[skip ci] ${{ contains(github.event.head_commit.message, '[skip ci]') }}" + + dev-image-test: + runs-on: ubuntu-18.04 + if: contains(github.event.head_commit.message, '[skip ci]') == false + steps: + - uses: actions/checkout@v2 + - run: make build + - run: make cirun cmd="npm ci" + - run: make ciall diff --git a/Dockerfile b/Dockerfile index 37f6317..c1734d4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,7 +13,7 @@ RUN apt-get update && \ rm -rf /var/lib/apt/lists/* WORKDIR /git -ENV GIT_VERSION="2.25.0" +ENV GIT_VERSION="2.26.0" RUN wget -q "https://github.com/git/git/archive/v${GIT_VERSION}.tar.gz" && \ tar -zxf "./v${GIT_VERSION}.tar.gz" && \ rm "./v${GIT_VERSION}.tar.gz" && \ @@ -24,5 +24,6 @@ RUN wget -q "https://github.com/git/git/archive/v${GIT_VERSION}.tar.gz" && \ make install WORKDIR /repo +ENV RUNNER_TEMP="/tmp" CMD [ "bash" ] diff --git a/Makefile b/Makefile index ae404e6..6df25cc 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,7 @@ IMAGE_NAME := actions_hugo_dev:latest NODE_VERSION := $(shell cat ./.nvmrc) DOCKER_BUILD := docker build . -t $(IMAGE_NAME) --build-arg NODE_VERSION=$(NODE_VERSION) DOCKER_RUN := docker run --rm -i -t -v ${PWD}:/repo -v ~/.gitconfig:/root/.gitconfig $(IMAGE_NAME) +DOCKER_RUN_CI := docker run --rm -v ${PWD}:/repo $(IMAGE_NAME) .PHONY: build @@ -14,10 +15,18 @@ build: run: $(DOCKER_RUN) $(cmd) +.PHONY: cirun +cirun: + $(DOCKER_RUN_CI) $(cmd) + .PHONY: test test: $(DOCKER_RUN) npm test -.PHONY: commit -commit: - $(DOCKER_RUN) git commit -m "$(msg)" +.PHONY: all +all: + $(DOCKER_RUN) npm run all + +.PHONY: ciall +ciall: + $(DOCKER_RUN_CI) npm run all diff --git a/package.json b/package.json index 79c8155..32eac04 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "npm": ">=6.13.7" }, "scripts": { + "all": "npm run format:check && npm run lint && npm test", "lint": "eslint ./{src,__tests__}/**/*.ts", "lint:fix": "eslint --fix ./{src,__tests__}/**/*.ts", "test": "jest --coverage --verbose", @@ -28,8 +29,7 @@ "lint-staged": { "src/**/*.ts": [ "prettier --check", - "eslint", - "jest --bail --findRelatedTests" + "eslint" ] }, "repository": {