Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: automated browser test on browserstack #553

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

set -ex

[[ -z "$DEPLOY_PATH" ]] && { echo "error: DEPLOY_PATH environment variable not set" >&2 ; exit 1 ; }
[[ -z "$COMMIT_TAG" ]] && { echo "error: COMMIT_TAG environment variable not set" >&2 ; exit 1 ; }
[[ -z "$COMMIT_SHORT_SHA" ]] && { echo "error: COMMIT_SHORT_SHA environment variable not set" >&2 ; exit 1 ; }
[[ -z "$GITHUB_USER" ]] && { echo "error: GITHUB_USER environment variable not set" >&2 ; exit 1 ; }
[[ -z "$GITHUB_TOKEN" ]] && { echo "error: GITHUB_TOKEN environment variable not set" >&2 ; exit 1 ; }
[[ -z "$DEPLOY_ENV" ]] && { echo "error: DEPLOY_ENV environment variable not set" >&2 ; exit 1 ; }
[[ -z "$RELEASE_ID" ]] && { echo "error: RELEASE_ID environment variable not set" >&2 ; exit 1 ; }
[[ -z "$RELEASE_TAG" ]] && { echo "error: RELEASE_TAG environment variable not set" >&2 ; exit 1 ; }
[[ -z "$GITHUB_USER" ]] && { echo "error: GITHUB_USER environment variable not set" >&2 ; exit 1 ; }
[[ -z "$GITHUB_TOKEN" ]] && { echo "error: GITHUB_TOKEN environment variable not set" >&2 ; exit 1 ; }

(
set +x # make sure we don't leak secrets here
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/browserstack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: 'BrowserStack'
on: [push, pull_request]

jobs:
ubuntu-job:
name: 'BrowserStack Test on Ubuntu'
runs-on: ubuntu-latest
steps:
- name: 'BrowserStack Env Setup'
uses: 'browserstack/github-actions/setup-env@master'
with:
username: ${{secrets.BROWSERSTACK_USERNAME}}
access-key: ${{secrets.BROWSERSTACK_ACCESS_KEY}}
build-name: BUILD_INFO
- name: 'BrowserStackLocal Setup'
uses: 'browserstack/github-actions/setup-local@master'
with:
local-testing: start
local-logging-level: all-logs
local-identifier: random
- name: 'checkout the repository demo'
uses: 'actions/checkout@v2'
- name: 'running npm install'
run: 'yarn install'
- name: 'running http-server'
run: './node_modules/.bin/http-server -p 8099 &'
- name: 'run test'
run: 'node browserstack.js'
- name: 'BrowserStackLocal Stop'
uses: 'browserstack/github-actions/setup-local@master'
with:
local-testing: stop
2 changes: 2 additions & 0 deletions .github/workflows/check-push.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Node CI
on:
push:
branches:
- '**'
env:
GITHUB_USER: dgrisham
GITHUB_TOKEN: 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
Expand Down
133 changes: 133 additions & 0 deletions .github/workflows/ci-release-development.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
name: Capsule Vue -- Development Deploy
on:
push:
tags:
- development
env:
GITHUB_USER: dgrisham
GITHUB_TOKEN: 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
DEPLOY_ENV: development

jobs:

install-dependencies:
runs-on: ubuntu-latest
container:
image: node:16-alpine
steps:

- uses: actions/checkout@v1

- name: install git
run: apk add --no-cache git

- name: yarn install
run: yarn install

# this copy of node_modules will be used for the rest of the workflow
- name: compress node_modules
run: tar -czf node_modules.tar.gz node_modules
- uses: actions/upload-artifact@v2
with:
name: node_modules.tar.gz
path: node_modules.tar.gz

lint:
needs: install-dependencies
runs-on: ubuntu-latest
container:
image: node:16-alpine
steps:

- uses: actions/checkout@v1

- uses: actions/download-artifact@v2
with:
name: node_modules.tar.gz
- name: extract node_modules
run: tar -xzf node_modules.tar.gz

- name: lint
run: yarn lint

release:
needs: lint
runs-on: ubuntu-latest
container:
image: node:16-alpine
steps:

- uses: actions/checkout@v1

- name: install git
run: apk add --no-cache git

- name: Setup .env
run: |
cat <<EOF >.env
CONTRACT_NAME="dev-1635323648697-81373157539648"
DOMAIN="https://alpha.capsule.social"
CAPSULE_SERVER="https://alpha.capsule.social/server"
ORBIT_URL="https://alpha.capsule.social/orbit"
TORUS_GOOGLE_VERIFIER="capsule-social-google-chris"
TORUS_GOOGLE_CLIENTID="653379121360-j8t9ua763vfvd86d1qjguonhrgqvkigo.apps.googleusercontent.com"
TORUS_DISCORD_VERIFIER="capsule-social-test-v2-discord"
TORUS_DISCORD_CLIENTID="906210984396468275"
EOF

- name: Set deploy environment vars
run: echo "RELEASE_ID=$(git rev-parse --short HEAD)" >> $GITHUB_ENV

- uses: actions/download-artifact@v2
with:
name: node_modules.tar.gz
- name: extract node_modules
run: tar -xzf node_modules.tar.gz

- name: build
run: yarn build:web

- name: Compress capsule-vue static site
run: |
[[ -d .app ]] || { echo "Missing .app, exiting" >&2 ; exit 1 ; }
build_name="capsule_vue-$DEPLOY_ENV-$RELEASE_ID"
mv .app $build_name
tar -czvf "${build_name}.tar.gz" "$build_name"
echo "BUILD_NAME=$build_name" >> $GITHUB_ENV
env:
DEPLOY_ENV: ${{ env.DEPLOY_ENV }}
RELEASE_ID: ${{ env.RELEASE_ID }}

- name: Upload build as release asset
uses: ncipollo/release-action@v1
with:
artifacts: ${{ env.BUILD_NAME }}.tar.gz
token: ${{ secrets.GITHUB_TOKEN }}
allowUpdates: true

deploy:
needs: release
runs-on: ubuntu-latest
container:
image: lexauw/ansible-alpine:latest
steps:

- uses: actions/checkout@v1

- name: install bash
run: apk add --no-cache bash

- name: Set deploy environment vars
run: |
echo "RELEASE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
echo "RELEASE_ID=$(git rev-parse --short HEAD)" >> $GITHUB_ENV

- name: Deploy updated images
run: ./.github/scripts/deploy.sh
env:
DEPLOY_ENV: ${{ env.DEPLOY_ENV }}
RELEASE_ID: ${{ env.RELEASE_ID }}
RELEASE_TAG: ${{ env.RELEASE_TAG }}
GITHUB_USER: ${{ env.GITHUB_USER }}
GITHUB_TOKEN: ${{ env.GITHUB_TOKEN }}
ANSIBLE_PRIVATE_KEY: ${{ secrets.ANSIBLE_PRIVATE_KEY }}
133 changes: 133 additions & 0 deletions .github/workflows/ci-release-production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
name: Capsule Vue -- Production Deploy
on:
release:
types: [published]
env:
GITHUB_USER: dgrisham
GITHUB_TOKEN: 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
DEPLOY_ENV: production

jobs:

install-dependencies:
runs-on: ubuntu-latest
container:
image: node:16-alpine
steps:

- uses: actions/checkout@v1

- name: install git
run: apk add --no-cache git

- name: yarn install
run: yarn install

# this copy of node_modules will be used for the rest of the workflow
- name: compress node_modules
run: tar -czf node_modules.tar.gz node_modules
- uses: actions/upload-artifact@v2
with:
name: node_modules.tar.gz
path: node_modules.tar.gz

lint:
needs: install-dependencies
runs-on: ubuntu-latest
container:
image: node:16-alpine
steps:

- uses: actions/checkout@v1

- uses: actions/download-artifact@v2
with:
name: node_modules.tar.gz
- name: extract node_modules
run: tar -xzf node_modules.tar.gz

- name: lint
run: yarn lint

release:
needs: lint
runs-on: ubuntu-latest
container:
image: node:16-alpine
steps:

- uses: actions/checkout@v1

- name: install git
run: apk add --no-cache git

- name: Set DEPLOY_ENV + DEPLOY_TARGET in github env
run: |
cat <<EOF >.env
CONTRACT_NAME="capsule-beta.testnet"
DOMAIN="https://blogchain.app"
CAPSULE_SERVER="https://blogchain.app/server"
ORBIT_URL="https://node1.blogchain.app"
TORUS_GOOGLE_VERIFIER="blogchain-app-production"
TORUS_GOOGLE_CLIENTID="367906518235-1gh9efo0518u43fnaj3qfgob64fv1o8p.apps.googleusercontent.com"
TORUS_DISCORD_VERIFIER="blogchain-app-discord-production"
TORUS_DISCORD_CLIENTID="947888768269033512"
TORUS_NETWORK=mainnet
EOF

- name: Set deploy environment vars
run: echo "RELEASE_ID=$(git rev-parse --short HEAD)" >> $GITHUB_ENV

- uses: actions/download-artifact@v2
with:
name: node_modules.tar.gz
- name: extract node_modules
run: tar -xzf node_modules.tar.gz

- name: build
run: yarn build:web

- name: Compress capsule-vue static site
run: |
[[ -d .app ]] || { echo "Missing .app, exiting" >&2 ; exit 1 ; }
build_name="capsule_vue-$DEPLOY_ENV-$RELEASE_ID"
mv .app $build_name
tar -czvf "${build_name}.tar.gz" "$build_name"
echo "BUILD_NAME=$build_name" >> $GITHUB_ENV
env:
DEPLOY_ENV: ${{ env.DEPLOY_ENV }}
RELEASE_ID: ${{ env.RELEASE_ID }}

- name: Upload build as release asset
uses: ncipollo/release-action@v1
with:
artifacts: ${{ env.BUILD_NAME }}.tar.gz
token: ${{ secrets.GITHUB_TOKEN }}
allowUpdates: true

deploy:
needs: release
runs-on: ubuntu-latest
container:
image: lexauw/ansible-alpine:latest
steps:

- uses: actions/checkout@v1

- name: install bash
run: apk add --no-cache bash

- name: Set deploy environment vars
run: |
echo "RELEASE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
echo "RELEASE_ID=$(git rev-parse --short HEAD)" >> $GITHUB_ENV

- name: Deploy updated images
run: ./.github/scripts/deploy.sh
env:
DEPLOY_ENV: ${{ env.DEPLOY_ENV }}
RELEASE_ID: ${{ env.RELEASE_ID }}
RELEASE_TAG: ${{ env.RELEASE_TAG }}
GITHUB_USER: ${{ env.GITHUB_USER }}
GITHUB_TOKEN: ${{ env.GITHUB_TOKEN }}
ANSIBLE_PRIVATE_KEY: ${{ secrets.ANSIBLE_PRIVATE_KEY }}
Loading