ci: improvements to Github Actions architecture

This commit is contained in:
Hank Stoever
2020-12-14 16:04:10 -08:00
parent 1b168333d7
commit b577e54b57
18 changed files with 762 additions and 641 deletions

31
.github/actions/code-checks/action.yml vendored Normal file
View File

@@ -0,0 +1,31 @@
name: 'Code Checks'
description: 'Run tests, linting, and other common jobs'
runs:
using: 'composite'
steps:
- name: Install yarn dependencies
run: yarn --frozen-lockfile
shell: bash
- name: Lint
run: yarn lint
shell: bash
- name: Typecheck
run: yarn typecheck
shell: bash
- name: Keychain tests
run: yarn test
shell: bash
working-directory: packages/keychain
- name: App unit tests
run: yarn test:unit
shell: bash
working-directory: packages/app
- name: Build extension
run: sh build-ext.sh
shell: bash
- name: Build web apps
run: yarn lerna run prod:web --parallel
shell: bash
- name: Setup screenshots
shell: bash
run: mkdir packages/app/tests/screenshots

View File

@@ -0,0 +1,21 @@
name: 'Integration Tests'
description: 'Run integration tests'
runs:
using: 'composite'
steps:
- name: Clear node_modules
shell: bash
run: rm -rf node_modules
- name: Install dependencies
shell: bash
run: yarn --frozen-lockfile
- name: Build web apps
shell: bash
run: yarn lerna run prod:web --parallel
- name: Integration Tests
shell: bash
run: |
yarn http-server packages/app/dist -p 8080 -s &
yarn http-server packages/test-app/dist -p 3000 -s &
cd packages/app &&
yarn test:integration

View File

@@ -1,53 +0,0 @@
name: Build Extension
on: [push, pull_request]
jobs:
build-extension:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set Node Version
uses: actions/setup-node@v2-beta
with:
node-version: 12.16.1
- name: Restore lerna cache
id: lerna-cache
uses: actions/cache@v2
with:
path: |
node_modules
*/*/node_modules
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
- uses: lucasmotta/pull-request-sticky-header@1.0.0
with:
header: '> [Download the latest builds](https://github.com/blockstack/ux/actions/runs/${{ github.run_id }}).'
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install monorepo deps
run: yarn --frozen-lockfile
if: steps.lerna-cache.outputs.cache-hit != 'true'
- name: Build extension
run: sh build-ext.sh
- uses: actions/upload-artifact@v2
name: Upload Extension Zip
with:
name: connect-extension
path: connect-extension.zip
- name: Sign Production Firefox version
if: github.ref == 'refs/heads/master'
run: yarn web-ext sign --channel=listed
env:
WEB_EXT_API_KEY: ${{ secrets.WEB_EXT_API_KEY }}
WEB_EXT_API_SECRET: ${{ secrets.WEB_EXT_API_SECRET }}
- name: Sign Firefox extension
if: github.ref != 'refs/heads/master'
run: yarn web-ext sign --channel=unlisted
env:
WEB_EXT_API_KEY: ${{ secrets.WEB_EXT_API_KEY }}
WEB_EXT_API_SECRET: ${{ secrets.WEB_EXT_API_SECRET }}
- uses: actions/upload-artifact@v2
name: Upload Firefox Add-On XPI
if: always()
with:
name: connect-addon
path: web-ext-artifacts/*.xpi

View File

@@ -1,13 +0,0 @@
name: Commitlint
on: [pull_request]
jobs:
lint:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: wagoid/commitlint-github-action@v1

View File

@@ -1,108 +0,0 @@
name: Deploy Blockstack Apps
on: [pull_request]
jobs:
blockstack-app-deployments:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set Node Version
uses: actions/setup-node@v2-beta
with:
node-version: 12.16.1
- name: Restore lerna cache
id: lerna-cache
uses: actions/cache@v2
with:
path: |
node_modules
*/*/node_modules
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
- name: Install monorepo deps
run: yarn --frozen-lockfile
if: steps.lerna-cache.outputs.cache-hit != 'true'
- name: Build connect-ui
run: yarn lerna run build --scope @stacks/connect-ui
- name: Build Blockstack App
run: yarn prod:web
working-directory: packages/app
- name: Copy Blockstack App vercel.json
uses: canastro/copy-file-action@master
with:
source: 'packages/app/vercel.json'
target: 'packages/app/dist/vercel.json'
- name: Deploy Blockstack App with Vercel
uses: amondnet/vercel-action@d4e0a9f
id: vercel-deployment-blockstack-app
if: github.event_name == 'pull_request'
with:
vercel-token: ${{ secrets.VERCEL_TOKEN }}
vercel-org-id: ${{ secrets.ORG_ID }}
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID_APP }}
scope: ${{ secrets.VERCEL_SCOPE }}
working-directory: packages/app/dist
github-comment: false
alias-domains: pr-{{ PR_NUMBER }}.app.stacks.engineering
- name: Build Blockstack Test App
env:
AUTH_ORIGIN: ${{ steps.vercel-deployment-blockstack-app.outputs.preview-url }}
run: yarn prod:web
working-directory: packages/test-app
- name: Copy Blockstack Test App vercel.json
uses: canastro/copy-file-action@master
with:
source: 'packages/test-app/vercel.json'
target: 'packages/test-app/dist/vercel.json'
- name: Deploy Blockstack Test App with Vercel
uses: amondnet/vercel-action@d4e0a9f
id: vercel-deployment-blockstack-test-app
if: github.event_name == 'pull_request'
with:
vercel-token: ${{ secrets.VERCEL_TOKEN }}
vercel-org-id: ${{ secrets.ORG_ID }}
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID_TEST_APP }}
scope: ${{ secrets.VERCEL_SCOPE }}
working-directory: packages/test-app/dist
github-comment: false
alias-domains: pr-{{ PR_NUMBER }}.testnet-demo.stacks.engineering
- name: Comment on PR
uses: actions/github-script@v2
id: comment
if: github.event_name == 'pull_request'
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const firstLine = `Deploy previews for _${{ steps.vercel-deployment-blockstack-app.outputs.preview-name }}_ and _${{ steps.vercel-deployment-blockstack-test-app.outputs.preview-name }}_ are ready!`;
const { data } = await github.issues.listComments({
...context.repo,
issue_number: context.issue.number,
});
const vercelPreviewURLComment = data.find((comment) =>
comment.body.includes(firstLine)
);
const commentId = vercelPreviewURLComment && vercelPreviewURLComment.id || undefined;
const commentBody = `
#### Deploy previews
${firstLine}
- [Blockstack App](${{ steps.vercel-deployment-blockstack-app.outputs.preview-url }})
- [Blockstack Testnet Demo App](${{ steps.vercel-deployment-blockstack-test-app.outputs.preview-url }})
Built with commit ${context.sha}.
`;
if(context.issue.number){
if (commentId) {
await github.issues.updateComment({
...context.repo,
comment_id: commentId,
body: commentBody,
});
} else {
await github.issues.createComment({
...context.repo,
issue_number: context.issue.number,
body: commentBody,
});
}
}

View File

@@ -1,51 +0,0 @@
name: Publish NPM Betas
on:
push:
branches-ignore:
- master
jobs:
publish_npm_betas:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set Node Version
uses: actions/setup-node@v2-beta
with:
node-version: 12.16.1
- name: Restore lerna cache
id: lerna-cache
uses: actions/cache@v2
with:
path: |
node_modules
*/*/node_modules
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
- name: Install monorepo deps
run: yarn --frozen-lockfile
if: steps.lerna-cache.outputs.cache-hit != 'true'
- name: Setup .npmrc
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc
- name: Get git branch
id: git-branch
run: echo "::set-output name=branch::$(git rev-parse --abbrev-ref HEAD | cut -d'/' -f2 )"
- name: Get git commit
id: git-commit
run: echo "::set-output name=sha::$(git rev-parse --short HEAD)"
- name: print preid
env:
BRANCH: ${{ steps.git-branch.outputs.branch }}
SHA: ${{ steps.git-commit.outputs.sha }}
run: echo $BRANCH.$SHA
- name: Setup git
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
- name: Publish to NPM
env:
BRANCH: ${{ steps.git-branch.outputs.branch }}
SHA: ${{ steps.git-commit.outputs.sha }}
run: yarn lerna publish prepatch --preid alpha.$SHA --dist-tag $BRANCH --yes --no-push

View File

@@ -1,8 +1,14 @@
name: UX
on: [push, workflow_dispatch]
name: Publish
on:
push:
branches:
- 'master'
tags:
- '**'
workflow_dispatch:
jobs:
test_keychain:
publish_extension:
runs-on: ubuntu-latest
steps:
- name: Checkout
@@ -12,83 +18,26 @@ jobs:
with:
node-version: 12.16.1
- name: Restore lerna cache
id: lerna-cache
uses: actions/cache@v2
with:
path: |
node_modules
*/*/node_modules
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
- name: Install monorepo deps
run: yarn --frozen-lockfile
if: steps.lerna-cache.outputs.cache-hit != 'true'
- name: Keychain tests
run: yarn lerna run test --scope @stacks/keychain
codecheck:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set Node Version
uses: actions/setup-node@v2-beta
- name: Build extension
run: sh build-ext.sh
- uses: actions/upload-artifact@v2
name: Upload Extension Zip
with:
node-version: 12.16.1
- name: Restore lerna cache
id: lerna-cache
uses: actions/cache@v2
with:
path: |
node_modules
*/*/node_modules
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
- name: Install monorepo deps
run: yarn --frozen-lockfile
if: steps.lerna-cache.outputs.cache-hit != 'true'
- name: Build connect-ui
run: yarn lerna run build --scope @stacks/connect-ui
- name: Lint
run: yarn lint
- name: Typecheck
run: yarn typecheck
publish:
needs: [test_keychain, codecheck]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Checkout master
run: git checkout master
- name: Set Node Version
uses: actions/setup-node@v2-beta
with:
node-version: 12.16.1
- name: Install monorepo deps (no cache)
run: yarn --frozen-lockfile
if: steps.lerna-cache.outputs.cache-hit != 'true'
- name: Build connect-ui
run: yarn lerna run build --scope @stacks/connect-ui
- name: Setup .npmrc
name: connect-extension
path: connect-extension.zip
- name: Sign Production Firefox version
run: yarn web-ext sign --channel=listed
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc
- name: Setup git
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
- name: Lerna Version
run: yarn lerna version --conventional-commits --no-push --yes
- name: Publish
run: yarn lerna publish from-package --conventional-commits --yes
- name: Push changes
uses: ad-m/github-push-action@fe38f0a
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
WEB_EXT_API_KEY: ${{ secrets.WEB_EXT_API_KEY }}
WEB_EXT_API_SECRET: ${{ secrets.WEB_EXT_API_SECRET }}
deploy-prod-apps:
needs: [publish]
runs-on: ubuntu-latest
steps:
- name: Checkout
@@ -108,8 +57,6 @@ jobs:
- name: Install monorepo deps
run: yarn --frozen-lockfile
if: steps.lerna-cache.outputs.cache-hit != 'true'
- name: Build connect-ui
run: yarn lerna run build --scope @stacks/connect-ui
- name: Build Blockstack App
run: yarn prod:web
working-directory: packages/app
@@ -150,3 +97,31 @@ jobs:
vercel-args: '--prod'
scope: ${{ secrets.VERCEL_SCOPE }}
working-directory: packages/test-app/dist
publish_npm:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Prepare repository
run: git checkout master
- name: Set Node Version
uses: actions/setup-node@v2-beta
with:
node-version: 12.16.1
- name: Restore lerna cache
id: lerna-cache
uses: actions/cache@v2
with:
path: |
node_modules
*/*/node_modules
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
- name: Install monorepo deps
run: yarn --frozen-lockfile
- name: Setup .npmrc
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc
- name: Publish
run: yarn lerna publish from-package --conventional-commits --yes

212
.github/workflows/pull_request.yml vendored Normal file
View File

@@ -0,0 +1,212 @@
name: Pull Request
on: [pull_request, workflow_dispatch]
jobs:
commitlint:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: wagoid/commitlint-github-action@v1
code_checks:
name: Code checks
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: lucasmotta/pull-request-sticky-header@1.0.0
with:
header: '> Try out this version of the Stacks Wallet - download [extension builds](https://github.com/blockstack/ux/actions/runs/${{ github.run_id }}), the [hosted version](https://pr-${{ github.event.number }}.app.stacks.engineering), or the [Stacks testnet demo app](https://pr-${{ github.event.number }}.testnet-demo.stacks.engineering)'
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set Node Version
uses: actions/setup-node@v2-beta
with:
node-version: 12.16.1
- uses: microsoft/playwright-github-action@v1
- name: Restore lerna cache
uses: actions/cache@v2
with:
path: |
node_modules
*/*/node_modules
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
- name: Code Checks
uses: ./.github/actions/code-checks
- uses: actions/upload-artifact@v2
name: Upload Extension Zip
with:
name: connect-extension
path: connect-extension.zip
integration_tests:
name: Integration tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set Node Version
uses: actions/setup-node@v2-beta
with:
node-version: 12.16.1
- uses: microsoft/playwright-github-action@v1
- name: Restore lerna cache
uses: actions/cache@v2
with:
path: |
node_modules
*/*/node_modules
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
- name: Integration Tests
uses: ./.github/actions/integration-tests
- uses: actions/upload-artifact@v2
if: always()
name: Upload Screenshots
with:
name: integration-test-screenshots
path: packages/app/tests/screenshots/
publish_npm_betas:
name: Publish NPM beta versions
runs-on: ubuntu-latest
if: github.repository == 'blockstack/ux'
steps:
- name: Checkout
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.ref }}
- name: Set Node Version
uses: actions/setup-node@v2-beta
with:
node-version: 12.16.1
- name: Restore lerna cache
uses: actions/cache@v2
with:
path: |
node_modules
*/*/node_modules
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
- name: Install monorepo deps
run: yarn --frozen-lockfile
- name: Setup .npmrc
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc
- name: Get git branch
id: git-branch
run: echo "::set-output name=branch::$(git rev-parse --abbrev-ref HEAD | cut -d'/' -f2 )"
- name: Get git commit
id: git-commit
run: echo "::set-output name=sha::$(git rev-parse --short HEAD)"
- name: print preid
env:
BRANCH: ${{ steps.git-branch.outputs.branch }}
SHA: ${{ steps.git-commit.outputs.sha }}
run: echo $BRANCH.$SHA
- name: Setup git
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
- name: Publish to NPM
env:
BRANCH: ${{ steps.git-branch.outputs.branch }}
SHA: ${{ steps.git-commit.outputs.sha }}
run: yarn lerna publish prepatch --preid alpha.$SHA --dist-tag $BRANCH --yes --no-push
publish_beta_web_apps:
name: Publich beta hosted versions
runs-on: ubuntu-latest
if: github.repository == 'blockstack/ux'
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set Node Version
uses: actions/setup-node@v2-beta
with:
node-version: 12.16.1
- name: Restore lerna cache
uses: actions/cache@v2
with:
path: |
node_modules
*/*/node_modules
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
- name: Install monorepo deps
run: yarn --frozen-lockfile
- name: Build Blockstack App
run: yarn prod:web
working-directory: packages/app
- name: Copy Blockstack App vercel.json
uses: canastro/copy-file-action@master
with:
source: 'packages/app/vercel.json'
target: 'packages/app/dist/vercel.json'
- name: Deploy Blockstack App with Vercel
uses: amondnet/vercel-action@d4e0a9f
id: vercel-deployment-blockstack-app
if: github.event_name == 'pull_request'
with:
vercel-token: ${{ secrets.VERCEL_TOKEN }}
vercel-org-id: ${{ secrets.ORG_ID }}
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID_APP }}
scope: ${{ secrets.VERCEL_SCOPE }}
working-directory: packages/app/dist
github-comment: false
alias-domains: pr-${{ github.event.number }}.app.stacks.engineering
- name: Build Blockstack Test App
env:
AUTH_ORIGIN: ${{ steps.vercel-deployment-blockstack-app.outputs.preview-url }}
run: yarn prod:web
working-directory: packages/test-app
- name: Copy Blockstack Test App vercel.json
uses: canastro/copy-file-action@master
with:
source: 'packages/test-app/vercel.json'
target: 'packages/test-app/dist/vercel.json'
- name: Deploy Blockstack Test App with Vercel
uses: amondnet/vercel-action@d4e0a9f
id: vercel-deployment-blockstack-test-app
if: github.event_name == 'pull_request'
with:
vercel-token: ${{ secrets.VERCEL_TOKEN }}
vercel-org-id: ${{ secrets.ORG_ID }}
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID_TEST_APP }}
scope: ${{ secrets.VERCEL_SCOPE }}
working-directory: packages/test-app/dist
github-comment: false
alias-domains: pr-${{ github.event.number }}.testnet-demo.stacks.engineering
publish_firefox_beta:
name: Publish beta firefox extension
runs-on: ubuntu-latest
if: github.repository == 'blockstack/ux'
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set Node Version
uses: actions/setup-node@v2-beta
with:
node-version: 12.16.1
- name: Restore lerna cache
uses: actions/cache@v2
with:
path: |
node_modules
*/*/node_modules
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
- name: Build extension
run: sh build-ext.sh
- name: Sign Firefox extension
run: yarn web-ext sign --channel=unlisted
env:
WEB_EXT_API_KEY: ${{ secrets.WEB_EXT_API_KEY }}
WEB_EXT_API_SECRET: ${{ secrets.WEB_EXT_API_SECRET }}
- uses: actions/upload-artifact@v2
name: Upload Firefox Add-On XPI
with:
name: connect-addon
path: web-ext-artifacts/*.xpi

95
.github/workflows/version.yml vendored Normal file
View File

@@ -0,0 +1,95 @@
name: Version
on:
push:
branches:
- 'master'
tags_ignore:
- '**'
workflow_dispatch:
env:
COMMIT_USER: Hiro DevOps
COMMIT_EMAIL: 45208873+blockstack-devops@users.noreply.github.com
jobs:
code_checks:
name: Code checks
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set Node Version
uses: actions/setup-node@v2-beta
with:
node-version: 12.16.1
- name: Restore lerna cache
uses: actions/cache@v2
with:
path: |
node_modules
*/*/node_modules
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
- name: Code Checks
uses: ./.github/actions/code-checks
- uses: actions/upload-artifact@v2
name: Upload Extension Zip
with:
name: connect-extension
path: connect-extension.zip
integration_tests:
name: Integration tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set Node Version
uses: actions/setup-node@v2-beta
with:
node-version: 12.16.1
- uses: microsoft/playwright-github-action@v1
- name: Restore lerna cache
uses: actions/cache@v2
with:
path: |
node_modules
*/*/node_modules
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
- name: Integration Tests
uses: ./.github/actions/integration-tests
- uses: actions/upload-artifact@v2
if: always()
name: Upload Screenshots
with:
name: integration-test-screenshots
path: packages/app/tests/screenshots/
version:
runs-on: ubuntu-latest
needs: [integration_tests, code_checks]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set Node Version
uses: actions/setup-node@v2-beta
with:
node-version: 12.16.1
- name: Restore lerna cache
uses: actions/cache@v2
with:
path: |
node_modules
*/*/node_modules
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
- name: Install dependencies
run: yarn --frozen-lockfile
- name: Setup git
run: |
git config --global user.email "${COMMIT_EMAIL}"
git config --global user.name "${COMMIT_USER}"
- name: Lerna Version
run: yarn lerna version --conventional-commits --no-push --yes
- name: Push changes
uses: ad-m/github-push-action@fe38f0a
with:
github_token: ${{ secrets.GH_TOKEN || secrets.GITHUB_TOKEN }}