From 93f1299f2d8cae71cc74610bb508313a2fb595ef Mon Sep 17 00:00:00 2001 From: Dominic Elm Date: Wed, 28 Oct 2020 16:58:17 +0100 Subject: [PATCH] ci: add github action --- .github/workflows/deployment.yml | 42 +++++++++++++++++++++ .github/workflows/main.yml | 61 ++++++++++++++++++++++++++++++ .travis.yml | 65 -------------------------------- package.json | 6 +-- 4 files changed, 106 insertions(+), 68 deletions(-) create mode 100644 .github/workflows/deployment.yml create mode 100644 .github/workflows/main.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml new file mode 100644 index 0000000..c5fcba7 --- /dev/null +++ b/.github/workflows/deployment.yml @@ -0,0 +1,42 @@ +name: Deployment + +on: + push: + branches: [master] + +jobs: + deploy: + runs-on: ubuntu-latest + name: Deploy to Github Pages + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup Node + uses: actions/setup-node@v1 + with: + node-version: '14' + + - name: Cache node_modules + uses: actions/cache@v2 + env: + cache-name: cache-node-modules + with: + path: '~/.npm' + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + + - name: Install + run: npm install + + - name: Build + run: npm run build:prerender-ghpages + + - name: Deploy + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./dist/browser diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..7c37ffc --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,61 @@ +name: Node CI + +on: + push: + branches: [master] + pull_request: + branches: [master] + +jobs: + lint: + runs-on: ubuntu-latest + name: Lint + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup Node + uses: actions/setup-node@v1 + with: + node-version: '14' + + - name: Cache node_modules + uses: actions/cache@v2 + env: + cache-name: cache-node-modules + with: + path: '~/.npm' + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + + - name: Install + run: npm install + + - name: Lint and Format + run: npm run lint:ci + e2e: + name: Cypress on Chrome + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + containers: [1, 2, 3, 4] + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Run Cypress + uses: cypress-io/github-action@v2 + with: + start: npm start + browser: chrome + record: true + wait-on: 'http://localhost:4200' + parallel: true + group: 'Demp App' + env: + CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 0244933..0000000 --- a/.travis.yml +++ /dev/null @@ -1,65 +0,0 @@ -sudo: required -language: node_js - -node_js: - - 12 - -before_install: - - npm install -g yarn - -branches: - only: - - master - -before_script: - # where is Cypress binary cached? - - yarn cypress cache path - # show me all versions of Cypress binary cached - - yarn cypress cache list - - yarn cypress verify - -dist: trusty -cache: - directories: - - $HOME/.cache - -addons: - chrome: stable - -notifications: - email: false - -defaults: &defaults - script: - - commitlint-travis - - npm run ci - -jobs: - include: - - stage: test - env: - - STAGE_NAME=4x-chrome - <<: *defaults - - stage: test - env: - - STAGE_NAME=4x-chrome - <<: *defaults - - stage: test - env: - - STAGE_NAME=4x-chrome - <<: *defaults - - stage: test - env: - - STAGE_NAME=4x-chrome - <<: *defaults - - stage: deploy - if: branch = master AND type != pull_request - script: - - npm run build:prerender-ghpages - deploy: - provider: pages - skip_cleanup: true - local_dir: dist/browser - github_token: $GH_TOKEN - on: - branch: master diff --git a/package.json b/package.json index 9fc4328..6e39963 100644 --- a/package.json +++ b/package.json @@ -27,11 +27,11 @@ "test": "ng test", "test:ci": "npm run test && start-server-and-test start http-get://localhost:4200 e2e:ci", "test:watch": "npm run test -- --watch", - "lint:check": "ng lint", - "lint:fix": "ng lint app --fix && ng lint ngx-drag-to-select --fix", "e2e": "cypress open", "e2e:ci": "cypress run --record --parallel --group $STAGE_NAME --browser chrome", - "ci": "npm run lint:check && npm run format:check && npm run test:ci", + "lint:check": "ng lint", + "lint:fix": "ng lint app --fix && ng lint ngx-drag-to-select --fix", + "lint:ci": "npm run lint:check && npm run format:check", "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0 -k ./projects/ngx-drag-to-select" }, "husky": {