Skip to content

Commit

Permalink
Merge pull request #479 from ForestAdmin/ci/move-to-github-actions
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentMolinie authored Jan 27, 2021
2 parents 60a8041 + 1bf6050 commit 70b54ec
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 52 deletions.
89 changes: 89 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Build, Test and Deploy

on:
push:
branches:
- master
- beta
pull_request:

env:
TZ: 'Europe/Paris'

jobs:
lint:
name: Linting
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[skip ci]')"
steps:
- name: Cancel previous running workflows
uses: fkirc/skip-duplicate-actions@master
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-node@v1
- uses: actions/cache@v2
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
- name: install dependencies
run: yarn install --frozen-lockfile --non-interactive --production=false
- name: Lint commit message
uses: wagoid/commitlint-github-action@v2
- name: lint Javascript
run: yarn lint

test:
name: Test
runs-on: ubuntu-latest
needs: [lint]
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-node@v1
- name: Cache node_modules
uses: actions/cache@v2
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
- name: Login on dockerhub
run: echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
- name: Start docker container
run: docker-compose up -d
- name: Send coverage
uses: paambaati/codeclimate-action@v2.7.4
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
with:
coverageCommand: yarn test:coverage

deploy:
name: Release package
runs-on: ubuntu-latest
needs: [test]
if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/beta')
steps:
- uses: actions/checkout@v2
with:
persist-credentials: false # GITHUB_TOKEN must not be set for the semantic release
- uses: actions/setup-node@v1
with:
node-version: 12.13.0
- uses: actions/cache@v2
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
- name: Build package
run: yarn build
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v2
id: semantic
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
GIT_AUTHOR_EMAIL: ${{ secrets.GIT_AUTHOR_EMAIL }}
GIT_AUTHOR_NAME: ${{ secrets.GIT_AUTHOR_NAME }}
GIT_COMMITTER_EMAIL: ${{ secrets.GIT_COMMITTER_EMAIL }}
GIT_COMMITTER_NAME: ${{ secrets.GIT_COMMITTER_NAME }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
37 changes: 0 additions & 37 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Forest Admin in Nodejs (Express.js & Mongoose)
[![npm package](https://badge.fury.io/js/forest-express-mongoose.svg)](https://badge.fury.io/js/forest-express-mongoose)
[![CI status](https://travis-ci.org/ForestAdmin/forest-express-mongoose.svg?branch=devel)](https://travis-ci.org/ForestAdmin/forest-express-mongoose)
[![CI status](https://github.com/ForestAdmin/forest-express-mongoose/workflows/.github/workflows/build.yml/badge.svg)](https://github.com/ForestAdmin/forest-express-mongoose/actions)
[![Test Coverage](https://api.codeclimate.com/v1/badges/4881f8b0b3cb806cd472/test_coverage)](https://codeclimate.com/github/ForestAdmin/forest-express-mongoose/test_coverage)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)

Expand Down
6 changes: 3 additions & 3 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// NOTICE: When a github "squash and merge" is performed, github add the PR link in the commit
// message using the format ` (#<PR_ID>)`. Travis provide the target branch of the build,
// message using the format ` (#<PR_ID>)`. Github provide the target branch of the build,
// so authorizing 4+5 = 9 characters more on master for the max header length should work
// until we reach PR #99999.

let maxHeaderLength = 100;

const prExtrasChars = 9;

const isCommitOnMaster = process.env.TRAVIS_BRANCH && process.env.TRAVIS_BRANCH === 'master';
const isPushEvent = process.env.GITHUB_EVENT_NAME === 'push';

if (isCommitOnMaster) {
if (isPushEvent) {
maxHeaderLength += prExtrasChars;
}

Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
"@babel/register": "7.10.1",
"@commitlint/cli": "11.0.0",
"@commitlint/config-conventional": "11.0.0",
"@commitlint/travis-cli": "11.0.0",
"@semantic-release/changelog": "5.0.1",
"@semantic-release/git": "9.0.0",
"@types/jest": "26.0.13",
Expand Down
11 changes: 1 addition & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1168,7 +1168,7 @@
exec-sh "^0.3.2"
minimist "^1.2.0"

"@commitlint/cli@11.0.0", "@commitlint/cli@^11.0.0":
"@commitlint/cli@11.0.0":
version "11.0.0"
resolved "https://registry.yarnpkg.com/@commitlint/cli/-/cli-11.0.0.tgz#698199bc52afed50aa28169237758fa14a67b5d3"
integrity sha512-YWZWg1DuqqO5Zjh7vUOeSX76vm0FFyz4y0cpGMFhrhvUi5unc4IVfCXZ6337R9zxuBtmveiRuuhQqnRRer+13g==
Expand Down Expand Up @@ -1299,15 +1299,6 @@
dependencies:
find-up "^5.0.0"

"@commitlint/travis-cli@11.0.0":
version "11.0.0"
resolved "https://registry.yarnpkg.com/@commitlint/travis-cli/-/travis-cli-11.0.0.tgz#cd0f25274e98daaf68732e53991b74347cde91b4"
integrity sha512-ZohGBnXeXv8hcba13fNz0HaCGy3CA4bz1A0PbyqwAzJA6Q85lBvLf1Wa78+Yxwo+PCZx85Vt8tpSrooHaHf2SA==
dependencies:
"@babel/runtime" "^7.11.2"
"@commitlint/cli" "^11.0.0"
execa "^4.0.0"

"@commitlint/types@^11.0.0":
version "11.0.0"
resolved "https://registry.yarnpkg.com/@commitlint/types/-/types-11.0.0.tgz#719cf05fcc1abb6533610a2e0f5dd1e61eac14fe"
Expand Down

0 comments on commit 70b54ec

Please sign in to comment.