From c9300fce2ba323a06db522453060a9bbaf251d84 Mon Sep 17 00:00:00 2001 From: Seth Foster Date: Wed, 6 Jan 2021 10:28:03 -0500 Subject: [PATCH] chore(labware-library): build, deploy lablib in gh actions (#7182) Moves builds and deploys of labware-library from TravisCI to Github Workflows --- .github/workflows/ll-test-build-deploy.yaml | 148 ++++++++++++++++++ .../shared-data-test-lint-deploy.yaml | 2 +- .travis.yml | 7 +- 3 files changed, 150 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/ll-test-build-deploy.yaml diff --git a/.github/workflows/ll-test-build-deploy.yaml b/.github/workflows/ll-test-build-deploy.yaml new file mode 100644 index 00000000000..7c3825f5f94 --- /dev/null +++ b/.github/workflows/ll-test-build-deploy.yaml @@ -0,0 +1,148 @@ +# Run tests, build labware library, and deploy it to sandbox + +name: 'Labware Library test, build, and deploy' + +on: + pull_request: + paths: + - 'labware-library/**' + - 'shared-data/labware/**' + - 'components/**' + - 'webpack-config/**' + - 'package.json' + - '.github/workflows/ll-test-build-deploy.yaml' + push: + paths: + - 'labware-library/**' + - 'shared-data/labware/**' + - 'components/**' + - 'webpack-config/**' + - 'package.json' + - '.github/workflows/ll-test-build-deploy.yaml' + branches: + - '*' + tags: + - 'labware-library*' + +defaults: + run: + shell: bash + +env: + CI: true + +jobs: + js-unit-test: + name: 'labware library unit tests' + runs-on: 'ubuntu-latest' + steps: + - uses: 'actions/checkout@v2' + - uses: 'actions/setup-node@v1' + with: + node-version: '12' + - name: 'cache yarn cache' + uses: actions/cache@v2 + with: + path: | + ${{ github.workspace }}/.yarn-cache + ${{ github.workspace }}/.npm-cache + key: js-${{ secrets.GH_CACHE_VERSION }}-${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + js-${{ secrets.GH_CACHE_VERSION }}-${{ runner.os }}-yarn- + - name: 'setup-js' + run: | + npm config set cache ./.npm-cache + yarn config set cache-folder ./.yarn-cache + make setup-js + - name: 'run labware library unit tests' + run: | + yarn jest --coverage=true --ci=true labware-library/ + e2e-test: + name: 'labware library e2e tests on ${{ matrix.os }}' + strategy: + matrix: + os: ['ubuntu-latest', 'macos-latest'] + runs-on: '${{ matrix.os }}' + steps: + - uses: 'actions/checkout@v2' + - uses: 'actions/setup-node@v1' + with: + node-version: '12' + - name: 'cache yarn cache' + uses: actions/cache@v2 + with: + path: | + ${{ github.workspace }}/.yarn-cache + ${{ github.workspace }}/.npm-cache + key: js-${{ secrets.GH_CACHE_VERSION }}-${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + js-${{ secrets.GH_CACHE_VERSION }}-${{ runner.os }}-yarn- + - name: 'setup-js' + run: | + npm config set cache ./.npm-cache + yarn config set cache-folder ./.yarn-cache + make setup-js + - name: 'test-e2e' + run: make -C labware-library test-e2e + build-ll: + name: 'build labware library artifact' + runs-on: 'ubuntu-latest' + if: github.event_name != 'pull_request' + steps: + - uses: 'actions/checkout@v2' + - uses: 'actions/setup-node@v1' + with: + node-version: '12' + - name: 'cache yarn cache' + uses: actions/cache@v2 + with: + path: | + ${{ github.workspace }}/.yarn-cache + ${{ github.workspace }}/.npm-cache + key: js-${{ secrets.GH_CACHE_VERSION }}-${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + js-${{ secrets.GH_CACHE_VERSION }}-${{ runner.os }}-yarn- + - name: 'setup-js' + run: | + npm config set cache ./.npm-cache + yarn config set cache-folder ./.yarn-cache + make setup-js + - name: 'build LL' + run: | + make -C labware-library + - name: 'upload github artifact' + uses: actions/upload-artifact@v2 + with: + name: 'll-artifact' + path: labware-library/dist + deploy-ll: + name: 'deploy LL artifact to S3' + runs-on: 'ubuntu-latest' + needs: ["js-unit-test", "e2e-test", "build-ll"] + if: github.event_name != 'pull_request' + steps: + - uses: 'actions/checkout@v2' + - uses: 'actions/setup-node@v1' + with: + node-version: '12' + - name: 'set complex environment variables' + id: 'set-vars' + uses: actions/github-script@v3.1 + with: + script: | + const { buildComplexEnvVars } = require(`${process.env.GITHUB_WORKSPACE}/.github/workflows/utils.js`) + buildComplexEnvVars(core, context) + - name: 'download LL build' + uses: 'actions/download-artifact@v2' + with: + name: ll-artifact + path: ./dist + - name: 'deploy builds to s3' + env: + AWS_ACCESS_KEY_ID: ${{ secrets.S3_SANDBOX_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_SANDBOX_SECRET }} + uses: './.github/actions/webstack/deploy-to-sandbox' + with: + domain: 'labware.opentrons.com' + distPath: './dist' + destPrefix: ${{ env.OT_BRANCH }} diff --git a/.github/workflows/shared-data-test-lint-deploy.yaml b/.github/workflows/shared-data-test-lint-deploy.yaml index 0ff9df7df0d..f244d6b08e1 100644 --- a/.github/workflows/shared-data-test-lint-deploy.yaml +++ b/.github/workflows/shared-data-test-lint-deploy.yaml @@ -70,7 +70,7 @@ jobs: buildComplexEnvVars(core, context) - name: Test run: make -C shared-data/python test - deploy: + python-deploy: name: 'shared-data package deploy' needs: [python-test] runs-on: 'ubuntu-latest' diff --git a/.travis.yml b/.travis.yml index d35365f32b9..20560c02052 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,7 +23,7 @@ jobs: include: # test, build, and upload for JavaScript projects - stage: test - name: 'JS unit tests; build Protocol Designer, Labware Library, Components Library' + name: 'JS unit tests; build Components Library' # node version pulled from .nvmrc language: node_js install: @@ -40,11 +40,6 @@ jobs: after_success: - make coverage deploy: - - # upload labware library artifacts to S3 - <<: *deploy_s3 - local-dir: labware-library/dist - bucket: $OT_LL_DEPLOY_BUCKET - upload-dir: $TRAVIS_BRANCH - # upload components library artifacts to S3 <<: *deploy_s3