From 38b87069f185bf750099bc3185821748f156dc52 Mon Sep 17 00:00:00 2001 From: Jen Jones Arnesen Date: Thu, 26 Nov 2020 15:03:42 +0100 Subject: [PATCH] chore: replace travis with github action (#1333) Based on the template workflow "verify-app". The cypress action has been moved to the verify action. --- .github/workflows/cypress.yml | 41 -------- .github/workflows/verify.yml | 187 ++++++++++++++++++++++++++++++++++ .travis.yml | 25 ----- package.json | 2 +- 4 files changed, 188 insertions(+), 67 deletions(-) delete mode 100644 .github/workflows/cypress.yml create mode 100644 .github/workflows/verify.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/cypress.yml b/.github/workflows/cypress.yml deleted file mode 100644 index c8138e469..000000000 --- a/.github/workflows/cypress.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: 'dhis2: test (cypress)' - -on: - push: - branches: - - master - pull_request: - -env: - SERVER_START_CMD: 'yarn cypress:start' - SERVER_URL: 'http://localhost:3000' - CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} - cypress_dhis2_api_stub_mode: 'DISABLED' - REACT_APP_DHIS2_BASE_URL: ${{ secrets.CYPRESS_DHIS2_BASE_URL }} - cypress_dhis2_base_url: ${{ secrets.CYPRESS_DHIS2_BASE_URL }} - cypress_dhis2_username: ${{ secrets.CYPRESS_DHIS2_USERNAME }} - cypress_dhis2_password: ${{ secrets.CYPRESS_DHIS2_PASSWORD }} - -jobs: - e2e: - runs-on: ubuntu-latest - if: "!contains(github.event.head_commit.message, '[skip ci]')" - strategy: - matrix: - containers: [1, 2, 3] - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Tests - uses: cypress-io/github-action@v2 - with: - record: true - parallel: true - start: ${{ env.SERVER_START_CMD }} - wait-on: ${{ env.SERVER_URL }} - wait-on-timeout: 60 - group: 'e2e' - env: - CI: true diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml new file mode 100644 index 000000000..4bc640764 --- /dev/null +++ b/.github/workflows/verify.yml @@ -0,0 +1,187 @@ +name: 'dhis2: verify (app)' + +on: + push: + branches: + +env: + GIT_AUTHOR_NAME: '@dhis2-bot' + GIT_AUTHOR_EMAIL: 'apps@dhis2.org' + GIT_COMMITTER_NAME: '@dhis2-bot' + GIT_COMMITTER_EMAIL: 'apps@dhis2.org' + GH_TOKEN: ${{secrets.DHIS2_BOT_GITHUB_TOKEN}} + CI: true + +jobs: + install: + runs-on: ubuntu-latest + if: "!contains(github.event.head_commit.message, '[skip ci]')" + + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: 12.x + + - uses: actions/cache@v2 + id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) + with: + path: '**/node_modules' + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + + - name: Install + if: steps.yarn-cache.outputs.cache-hit != 'true' + run: yarn install --frozen-lockfile + + build: + runs-on: ubuntu-latest + needs: install + if: "!contains(github.event.head_commit.message, '[skip ci]')" + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: 12.x + + - uses: actions/cache@v2 + id: yarn-cache + with: + path: '**/node_modules' + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + + - name: Build + run: yarn build + + - uses: actions/upload-artifact@v2 + with: + name: app-build + path: | + **/build + !**/node_modules + retention-days: 1 + + lint: + runs-on: ubuntu-latest + needs: install + if: "!contains(github.event.head_commit.message, '[skip ci]')" + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: 12.x + + - uses: actions/cache@v2 + id: yarn-cache + with: + path: '**/node_modules' + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + + - name: Lint + run: yarn lint + + test: + runs-on: ubuntu-latest + needs: install + if: "!contains(github.event.head_commit.message, '[skip ci]')" + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: 12.x + + - uses: actions/cache@v2 + id: yarn-cache + with: + path: '**/node_modules' + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + + # Can be removed if translations aren't required for tests, or if not using the App Platform + - name: Generate translations + run: yarn d2-app-scripts i18n generate + + - name: Test + run: yarn test + + e2e: + runs-on: ubuntu-latest + needs: install + if: "!contains(github.event.head_commit.message, '[skip ci]')" + + strategy: + matrix: + containers: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - uses: actions/setup-node@v1 + with: + node-version: 12.x + + - uses: actions/cache@v2 + id: yarn-cache + with: + path: '**/node_modules' + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + + - name: End-to-End tests + uses: cypress-io/github-action@v2 + with: + record: true + parallel: true + start: ${{ env.SERVER_START_CMD }} + wait-on: ${{ env.SERVER_URL }} + wait-on-timeout: 300 + cache-key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + group: 'e2e' + tag: ${{ github.event_name }} + env: + CI: true + CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} + COMMIT_INFO_MESSAGE: ${{ github.event.pull_request.title }} + SERVER_START_CMD: 'yarn cypress:start' + SERVER_URL: 'http://localhost:3000' + cypress_dhis2_api_stub_mode: 'DISABLED' + REACT_APP_DHIS2_BASE_URL: ${{ secrets.CYPRESS_DHIS2_BASE_URL }} + cypress_dhis2_base_url: ${{ secrets.CYPRESS_DHIS2_BASE_URL }} + cypress_dhis2_username: ${{ secrets.CYPRESS_DHIS2_USERNAME }} + cypress_dhis2_password: ${{ secrets.CYPRESS_DHIS2_PASSWORD }} + + publish: + runs-on: ubuntu-latest + needs: [build, lint, test, e2e] + if: "!contains(github.event.head_commit.message, '[skip ci]')" + steps: + - uses: actions/checkout@v2 + with: + token: ${{env.GH_TOKEN}} + + - uses: actions/setup-node@v1 + with: + node-version: 12.x + + - uses: actions/download-artifact@v2 + with: + name: app-build + + - uses: dhis2/deploy-build@master + with: + build-dir: build/app + github-token: ${{ env.GH_TOKEN }} + + release: + runs-on: ubuntu-latest + needs: [publish] + if: "github.event_name == 'push' && !contains(github.event.head_commit.message, '[skip ci]')" + steps: + - uses: actions/checkout@v2 + with: + token: ${{env.GH_TOKEN}} + + - uses: actions/setup-node@v1 + with: + node-version: 12.x + + - name: Publish release to GitHub + run: npx @dhis2/cli-utils release diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 579150154..000000000 --- a/.travis.yml +++ /dev/null @@ -1,25 +0,0 @@ -language: node_js -node_js: - - lts/* -env: - global: - - NODE_OPTIONS=--max_old_space_size=8192 - - CC_TEST_REPORTER_ID=daeae58060a32f8d37e835457e8b2a1f9af55a38694826f4f6628a30383314f6 - - secure: L/VfchxLzvDlaUL3GDNiRXqA9UMkqIoXXs3FteMdoo07mOaWfqA0PN/MnOwwsw8UwC5J+2LstxLyi/AN1mjs+2vMUeZGMMZKf40My10XiPZCHp0/uxRjEa9nZuQ0OIZBAwTOqp60qGPbK/h4PAcit3Wk0XPPYpL/FXReVDubIeLn72rvr9BnnYrBsIBS6/3bfZUT1bpLr2nadB1NerdN+UPl1oOVq6VS6CQ/NmGL0lSqsZfk6q+g2X9tkjeO37UYL40+9MGDq5pLBX0r8jCdiXknQciFx/AvCitiZ0sme8pX7uIz8P5ikFQKIRlD9DNJe2/q7f7DjR30gzg4BOQotIKvcFAuucGWGZpEQKdqv5XheXG2C0M/0uGOSun+kgTzTpr5e1qpYqt6HXYfN9HXcaJ3bMcriS1qjgo33ipLJTUotI85xQUiRpUFczPJ20D5u65NpUvOpP9+QO1vp2HdLW8yF+TT1qAwjunKZUwKbKdtnEAWDJArmdWZbpd6gHRu1e1IdKSZo5b1P0wABHXfGZExduhu+N6/LYVe1WBffLBD33gaJvZvf1E4aonNSzkhYLVQ9QOV4K/YIv4lGiKZeNrLvK5Ws9+WJPGMLsn6nLTzpPPQY4JzuVJRHQnsvgW/VjhP0URsPxUzQCQdZkQcjyainz/7cO9W1jS3foouDpk= -before_script: - - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 - > ./cc-test-reporter - - chmod +x ./cc-test-reporter - - './cc-test-reporter before-build' -script: - - npm run lint - - npm run build - - npm run coverage -after_script: - - './cc-test-reporter after-build -d --exit-code $TRAVIS_TEST_RESULT' -deploy: - - provider: script - script: npx --package @dhis2/deploy-build deploy-build d2-ci build/app - skip_cleanup: true - on: - all_branches: true diff --git a/package.json b/package.json index 4d0a718a9..de9b9d455 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "dashboard-app", + "name": "dashboards-app", "version": "31.0.1", "description": "DHIS2 Dashboards app", "private": true,