From 5360e453e7e84be2a2b8b0df42b89d030f53e7a1 Mon Sep 17 00:00:00 2001 From: Ole-Martin Bratteng Date: Thu, 10 Sep 2020 16:26:44 +0200 Subject: [PATCH 1/4] ci(gh-actions): create CI action for testing and linting --- .github/workflows/ci.yml | 50 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..56137bb1 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,50 @@ +name: Continuous Integration + +on: + push: + +jobs: + check: + runs-on: ubuntu-latest + strategy: + matrix: + node-version: ['10', '12', '14'] + name: "[v${{ matrix.node-version }}] lint and test" + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v2-beta + with: + node-version: ${{ matrix.node-version }} + + # Check if cache exists, based on the hash of the lockfile + - name: Cache node_modules + id: cache-node_modules + uses: actions/cache@v2 + with: + path: node_modules + key: ${{ runner.os }}-node-${{matrix.node-version}}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node-${{matrix.node-version}}- + ${{ runner.os }}-node- + ${{ runner.os }}- + + # If there is no cache available, we run npm installation in CI mode + - name: Install dependencies + if: steps.cache-node_modules.outputs.cache-hit != 'true' + run: npm ci + + - name: Lint + run: npm run lint + + - name: Run tests + run: npm run test + + # Build and check if it builds ok. + - name: Build + env: + BUNDLESIZE_GITHUB_TOKEN: ${{ secrets.BUNDLESIZE }} + run: npm run build From 2905629d14af582c561aa3675937ba02f1ab41c6 Mon Sep 17 00:00:00 2001 From: Ole-Martin Bratteng Date: Thu, 10 Sep 2020 15:16:49 +0200 Subject: [PATCH 2/4] ci(gh-actions): remove `.travis.yml` --- .travis.yml | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 8b015aa6..00000000 --- a/.travis.yml +++ /dev/null @@ -1,16 +0,0 @@ -language: node_js -sudo: false -node_js: - - 10 - - 12 - - 14 -cache: - directories: - - node_modules -install: - - npm install -script: - - npm run test - - npm run build -after_success: - - npm run release From e2420596d083f43117e5ed7c3b3a921b92ef8b44 Mon Sep 17 00:00:00 2001 From: Ole-Martin Bratteng Date: Thu, 10 Sep 2020 15:17:03 +0200 Subject: [PATCH 3/4] ci(gh-actions): remove `npm run build` from test command It is run in CI action --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8497ea30..478dd23c 100755 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "dev": "start-storybook -p 6006", "build": "rm -fr ./dist ./native && rollup -c && npm run test:size", "deploy:docs": "storybook-to-ghpages", - "test": "npm run test:tsc && npm run test:unit && npm run build", + "test": "npm run test:tsc && npm run test:unit", "test:unit": "npm run test:unit:web && npm run test:unit:native", "test:unit:web": "jest -c jest.web.config.js", "test:unit:native": "jest -c jest.native.config.js", From 3784f2bf8140f50ae50ce49d9d814af1756e6604 Mon Sep 17 00:00:00 2001 From: Ole-Martin Bratteng Date: Thu, 10 Sep 2020 15:47:56 +0200 Subject: [PATCH 4/4] ci(gh-actions): add a release workflow --- .github/workflows/release.yml | 92 +++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..f5c46e57 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,92 @@ +name: Release + +on: + push: + branches: + - master + +jobs: + prepare: + runs-on: ubuntu-latest + strategy: + matrix: + node-version: ['14'] + name: "[v${{ matrix.node-version }}] check" + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v2-beta + with: + node-version: ${{ matrix.node-version }} + + # Check if cache exists, based on the hash of the lockfile + - name: Cache node_modules + id: cache-node_modules + uses: actions/cache@v2 + with: + path: node_modules + key: ${{ runner.os }}-node-${{matrix.node-version}}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node-${{matrix.node-version}}- + ${{ runner.os }}-node- + ${{ runner.os }}- + + # If there is no cache available, we run npm installation in CI mode + - name: Install dependencies + if: steps.cache-node_modules.outputs.cache-hit != 'true' + run: npm ci + + - name: Lint + run: npm run lint + + - name: Run tests + run: npm run test + + build-and-release: + runs-on: ubuntu-latest + needs: prepare + strategy: + matrix: + node-version: ['14'] + name: "[v${{ matrix.node-version }}] release" + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v2-beta + with: + node-version: ${{ matrix.node-version }} + + # Check if cache exists, based on the hash of the lockfile + - name: Cache node_modules + id: cache-node_modules + uses: actions/cache@v2 + with: + path: node_modules + key: ${{ runner.os }}-node-${{matrix.node-version}}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node-${{matrix.node-version}}- + ${{ runner.os }}-node- + ${{ runner.os }}- + + # If there is no cache available, we run npm installation in CI mode + - name: Install dependencies + if: steps.cache-node_modules.outputs.cache-hit != 'true' + run: npm ci + + # Build and check if it builds ok. + - name: Build + env: + BUNDLESIZE_GITHUB_TOKEN: ${{ secrets.BUNDLESIZE }} + run: npm run build + + - name: Release + env: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: npm run release