1
0
mirror of https://github.com/SomboChea/ui synced 2024-11-05 14:14:26 +07:00

Merge pull request #127 from verdaccio/refactor-ci

chore: refactor ci
This commit is contained in:
Sergio Hg 2019-09-11 22:55:04 +02:00 committed by GitHub
commit 3a889b67ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 2054 additions and 2889 deletions

View File

@ -1,31 +1,25 @@
version: 2 version: 2
aliases: aliases:
- &repo_path
~/ui-theme
- &defaults - &defaults
working_directory: ~/ui-theme working_directory: *repo_path
- &node11_executor - &node_latest_executor
docker: docker:
- image: circleci/node:11.10.1 - image: circleci/node:latest
- &node8_executor - &node_lts_executor
docker: docker:
- image: circleci/node:8 - image: circleci/node:lts
- &node10_executor
docker:
- image: circleci/node:10
- &default_executor - &default_executor
<<: *node10_executor <<: *node_latest_executor
- &repo_key
repo-{{ .Branch }}-{{ .Revision }}
- &coverage_key
coverage-{{ .Branch }}-{{ .Revision }}
- &base_config_key
base-config-{{ .Branch }}-{{ .Revision }}
- &yarn_cache_key - &yarn_cache_key
yarn-sha-{{ checksum "yarn.lock" }} yarn-sha-{{ checksum "yarn.lock" }}
- &coverage_key
coverage-{{ .Branch }}-{{ .Revision }}
- &restore_repo - &restore_repo
restore_cache: attach_workspace:
keys: at: *repo_path
- *repo_key
- &ignore_non_dev_branches - &ignore_non_dev_branches
filters: filters:
tags: tags:
@ -36,7 +30,7 @@ aliases:
- &execute_on_release - &execute_on_release
filters: filters:
tags: tags:
only: /(v)?[0-9]+(\.[0-9]+)*/ only: /v?[0-9]+(\.[0-9]+)*([-+\.][a-zA-Z0-9]+)*/
branches: branches:
ignore: ignore:
- /.*/ - /.*/
@ -48,21 +42,11 @@ jobs:
steps: steps:
- *restore_repo - *restore_repo
- checkout - checkout
- restore_cache:
key: *base_config_key
- run:
name: 'Base environment setup'
command: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
- save_cache:
key: *base_config_key
paths:
- ~/.npmrc
- ~/.gitconfig
- restore_cache: - restore_cache:
key: *yarn_cache_key key: *yarn_cache_key
- run: - run:
name: Install Js dependencies name: Install dependencies
command: yarn install --no-progress --registry https://registry.verdaccio.org --no-lockfile command: yarn install --frozen-lockfile
- run: - run:
name: Build project name: Build project
command: yarn run build command: yarn run build
@ -72,10 +56,20 @@ jobs:
- ~/.yarn - ~/.yarn
- ~/.cache/yarn - ~/.cache/yarn
- node_modules - node_modules
- save_cache: - persist_to_workspace:
key: *repo_key root: *repo_path
paths: paths:
- ~/ui-theme - ./*
lint:
<<: *defaults
<<: *default_executor
steps:
- *restore_repo
- run:
name: Lint code
command: yarn lint
test_bundlesize: test_bundlesize:
<<: *defaults <<: *defaults
<<: *default_executor <<: *default_executor
@ -85,37 +79,28 @@ jobs:
name: Test BundleSize name: Test BundleSize
command: yarn test:size command: yarn test:size
test_node11: test_node_latest:
<<: *defaults <<: *defaults
<<: *node11_executor <<: *node_latest_executor
steps: steps:
- *restore_repo - *restore_repo
- run: - run:
name: Test with Node 11 name: Test with Node (Latest)
command: yarn test command: yarn test
test_node8:
<<: *defaults
<<: *node8_executor
steps:
- *restore_repo
- run:
name: Test with Node 8
command: yarn test
test_node10:
<<: *defaults
<<: *node10_executor
steps:
- *restore_repo
- run:
name: Test with Node 10
command: yarn run test
- save_cache: - save_cache:
key: *coverage_key key: *coverage_key
paths: paths:
- coverage - coverage
test_node_lts:
<<: *defaults
<<: *node_lts_executor
steps:
- *restore_repo
- run:
name: Test with Node (LTS)
command: yarn test
coverage: coverage:
<<: *defaults <<: *defaults
<<: *default_executor <<: *default_executor
@ -140,8 +125,9 @@ jobs:
<<: *default_executor <<: *default_executor
steps: steps:
- *restore_repo - *restore_repo
- restore_cache: - run:
key: *base_config_key name: 'Setup publish credentials'
command: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
- run: - run:
name: Publish name: Publish
command: yarn publish command: yarn publish
@ -152,29 +138,31 @@ workflows:
jobs: jobs:
- prepare: - prepare:
<<: *ignore_non_dev_branches <<: *ignore_non_dev_branches
- test_node11: - lint:
requires:
- prepare
<<: *ignore_non_dev_branches
- test_node8:
requires:
- prepare
<<: *ignore_non_dev_branches
- test_node10:
requires: requires:
- prepare - prepare
<<: *ignore_non_dev_branches <<: *ignore_non_dev_branches
- test_bundlesize: - test_bundlesize:
requires: requires:
- test_node11 - prepare
- test_node8 <<: *ignore_non_dev_branches
- test_node10 - test_node_latest:
requires:
- prepare
<<: *ignore_non_dev_branches
- test_node_lts:
requires:
- prepare
<<: *ignore_non_dev_branches <<: *ignore_non_dev_branches
- coverage: - coverage:
requires: requires:
- test_bundlesize - test_node_latest
<<: *ignore_non_dev_branches <<: *ignore_non_dev_branches
- publish_package: - publish_package:
requires: requires:
- lint
- test_bundlesize
- test_node_latest
- test_node_lts
- coverage - coverage
<<: *execute_on_release <<: *execute_on_release

67
.github/main.workflow vendored
View File

@ -1,67 +0,0 @@
################################################
# Workflow for a github release when a tag is
# pushed
################################################
workflow "github release" {
resolves = [
"release.github",
"release.lint",
]
on = "push"
}
action "release.filter" {
uses = "actions/bin/filter@master"
args = "tag v*"
}
action "release.install" {
uses = "docker://node:10"
needs = ["release.filter"]
args = "yarn install"
}
action "release.build" {
uses = "docker://node:10"
needs = ["release.install"]
args = "yarn run build"
}
action "release.lint" {
uses = "docker://node:10"
needs = ["release.install"]
args = "yarn run lint"
}
action "release.test" {
uses = "docker://node:10"
needs = ["release.build"]
args = "yarn run test"
}
action "release.auth" {
needs = ["release.test"]
uses = "actions/bin/filter@master"
args = ["actor", "octocat", "torvalds"]
}
action "release.npm.publish" {
needs = ["release.auth"]
uses = "docker://node:10"
args = "sh scripts/publish.sh"
secrets = [
"REGISTRY_AUTH_TOKEN",
]
env = {
REGISTRY_URL = "registry.npmjs.org"
}
}
action "release.github" {
needs = ["release.npm.publish"]
uses = "docker://node:10"
args = "sh scripts/github-release.sh"
secrets = [
"GITHUB_TOKEN",
]
}

View File

@ -1,28 +1,28 @@
name: Node CI name: CI
on: [push] on: push
jobs: jobs:
ci: build_test_lint:
name: Test on node ${{ matrix.node_version }} and ${{ matrix.os }} name: Node ${{ matrix.node_version }} and ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy: strategy:
fail-fast: false
matrix: matrix:
node_version: [8, 10, 12] node_version: [10, 12]
os: [ubuntu-latest, windows-latest, macOS-latest] os: [ubuntu-latest, windows-latest, macOS-latest]
runs-on: ${{ matrix.os }}
steps: steps:
- uses: actions/checkout@v1 - uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node_version }} - name: Use Node.js ${{ matrix.node_version }}
uses: actions/setup-node@v1 uses: actions/setup-node@v1
with: with:
version: ${{ matrix.node_version }} version: ${{ matrix.node_version }}
- name: Install
- name: Use Yarn 1.17.2 run: yarn install --frozen-lockfile
run: | - name: Build
npm install -g yarn@1.17.2 run: yarn build
- name: yarn build - name: Lint
run: | run: yarn lint
yarn install
yarn lint
yarn build

View File

@ -1,4 +1,5 @@
{ {
"endOfLine": "auto",
"useTabs": false, "useTabs": false,
"printWidth": 160, "printWidth": 160,
"tabWidth": 2, "tabWidth": 2,

View File

@ -152,7 +152,7 @@
"test:size": "bundlesize", "test:size": "bundlesize",
"lint": "npm run lint:js && npm run lint:css", "lint": "npm run lint:js && npm run lint:css",
"lint:js": "npm run type-check && eslint . --ext .js,.ts,.tsx", "lint:js": "npm run type-check && eslint . --ext .js,.ts,.tsx",
"lint:css": "stylelint 'src/**/styles.ts'", "lint:css": "stylelint \"src/**/styles.ts\"",
"coverage:publish": "codecov", "coverage:publish": "codecov",
"pre:webpack": "rimraf static/*", "pre:webpack": "rimraf static/*",
"prepublish": "in-publish && npm run build || not-in-publish", "prepublish": "in-publish && npm run build || not-in-publish",

View File

@ -27,7 +27,8 @@ describe('<Version /> component', () => {
cleanup(); cleanup();
}); });
test('should render the component in default state', () => { // FIXME: this test is not deterministic (writes `N days ago` in the snapshot, where N is random number)
test.skip('should render the component in default state', () => {
const wrapper = mount( const wrapper = mount(
<MemoryRouter> <MemoryRouter>
<Versions /> <Versions />

File diff suppressed because one or more lines are too long

4710
yarn.lock

File diff suppressed because it is too large Load Diff