Skip to content

Commit

Permalink
ci: rework ci LW-10413
Browse files Browse the repository at this point in the history
  • Loading branch information
pczeglik-iohk committed Apr 29, 2024
1 parent 6dd077d commit 31e15f9
Show file tree
Hide file tree
Showing 31 changed files with 1,787 additions and 702 deletions.
60 changes: 60 additions & 0 deletions .github/actions/build/app/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: buildapp
description: Build app

inputs:
DIR:
description: 'app directory'
required: true
NAME:
description: 'app name'
required: true
LACE_EXTENSION_KEY:
description: 'Public extended manifest key'
required: true
BUILD_DEV_PREVIEW:
description: 'Build developer preview of Lace'
required: false
default: 'false'
POSTHOG_PRODUCTION_TOKEN_MAINNET:
description: 'Post hog production mainnet token'
required: false
default: ''
POSTHOG_PRODUCTION_TOKEN_PREPROD:
description: 'Post hog production preprod token'
required: false
default: ''
POSTHOG_PRODUCTION_TOKEN_PREVIEW:
description: 'Post hog production preview token'
required: false
default: ''
PRODUCTION_MODE_TRACKING:
description: 'Enable analytics tracking in production'
required: false
default: 'false'

runs:
using: 'composite'

steps:
- name: Code check
uses: ./.github/actions/check
with:
DIR: ${{ inputs.DIR }}

- name: Build ${{ inputs.NAME }}
run: yarn build
shell: bash
working-directory: ${{ inputs.DIR }}
env:
LACE_EXTENSION_KEY: ${{ inputs.LACE_EXTENSION_KEY }}
BUILD_DEV_PREVIEW: ${{ inputs.BUILD_DEV_PREVIEW }}
POSTHOG_PRODUCTION_TOKEN_MAINNET: ${{ inputs.POSTHOG_PRODUCTION_TOKEN_MAINNET }}
POSTHOG_PRODUCTION_TOKEN_PREPROD: ${{ inputs.POSTHOG_PRODUCTION_TOKEN_PREPROD }}
POSTHOG_PRODUCTION_TOKEN_PREVIEW: ${{ inputs.POSTHOG_PRODUCTION_TOKEN_PREVIEW }}
PRODUCTION_MODE_TRACKING: ${{ inputs.PRODUCTION_MODE_TRACKING }}

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.NAME }}
path: ${{ inputs.DIR }}/dist
30 changes: 30 additions & 0 deletions .github/actions/build/package/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: build
description: Build package

inputs:
DIR:
description: 'package directory'
required: true
NAME:
description: 'package name'
required: true

runs:
using: 'composite'

steps:
- name: Code check
uses: ./.github/actions/check
with:
DIR: ${{ inputs.DIR }}

- name: Build ${{ inputs.NAME }}
run: yarn build
shell: bash
working-directory: ${{ inputs.DIR }}

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.NAME }}
path: ${{ inputs.DIR }}/dist
26 changes: 26 additions & 0 deletions .github/actions/check/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: check
description: Code check

inputs:
DIR:
description: 'package directory'
required: true

runs:
using: 'composite'

steps:
- name: Format check
run: yarn format-check
shell: bash
working-directory: ${{ inputs.DIR }}

- name: Code check
run: yarn lint
shell: bash
working-directory: ${{ inputs.DIR }}

- name: Type check
run: yarn type-check
shell: bash
working-directory: ${{ inputs.DIR }}
42 changes: 42 additions & 0 deletions .github/actions/chromatic/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: deploy chromatic
description: Deploy storybook to Chromatic

inputs:
TOKEN:
description: 'Chromatic token'
required: true
DIR:
description: 'Package directory'
required: true
NAME:
description: 'Package name'
required: true

runs:
using: 'composite'

steps:
- name: Tests
working-directory: ./${{ inputs.DIR }}
run: yarn test-storybook:ci
shell: bash

- name: Publish to Chromatic
if: github.ref != 'refs/heads/main'
uses: chromaui/action@v1
with:
projectToken: ${{ inputs.TOKEN }}
workingDir: ./${{ inputs.DIR }}
buildScriptName: build-storybook
onlyChanged: true
exitOnceUploaded: true

- name: Publish to Chromatic and auto accept changes
if: github.ref == 'refs/heads/main'
uses: chromaui/action@v1
with:
projectToken: ${{ inputs.TOKEN }}
autoAcceptChanges: true
workingDir: ./${{ inputs.DIR }}
onlyChanged: true
exitOnceUploaded: true
35 changes: 35 additions & 0 deletions .github/actions/install/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: setup and install
description: Setup Node.js and install dependencies

inputs:
WALLET_PASSWORD:
description: 'Test wallet password'
required: true

runs:
using: 'composite'
steps:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'yarn'

- name: Node modules cache
uses: actions/cache@v4
with:
path: |
node_modules
**/node_modules
key: ${{ runner.os }}-${{ hashFiles('yarn.lock') }}

- name: Install dependencies
run: yarn install --immutable --inline-builds
shell: bash

- name: Decrypt test data
working-directory: ./packages/e2e-tests
run: ./decrypt_secret.sh
shell: bash
env:
WALLET_1_PASSWORD: ${{ inputs.WALLET_PASSWORD }}
117 changes: 117 additions & 0 deletions .github/actions/test/smoke/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
name: smoke
description: Execute e2e smoke tests

inputs:
WALLET_PASSWORD:
description: 'Test wallet password'
required: true

TEST_DAPP_URL:
description: 'Test DApp Url'
required: true

GITHUB_TOKEN:
description: 'Github token'
required: true

E2E_AWS_ACCESS_KEY_ID:
description: 'AWS access key id'
required: true

E2E_AWS_SECRET_ACCESS_KEY:
description: 'AWS secret access key'
required: true

E2E_REPORTS_USER:
description: 'E2E reports user'
required: true

E2E_REPORTS_PASSWORD:
description: 'E2E reports password'
required: true

E2E_REPORTS_URL:
description: 'E2E reports url'
required: true

RUN:
description: 'Runner number'
required: true

TAGS:
description: 'tags'
required: false
default: '@Smoke and @Testnet'

BROWSER:
description: 'browser'
required: false
default: 'chrome'

DISPLAY:
description: ''
required: false
default: ':99.0'

runs:
using: 'composite'

steps:
- name: Start XVFB
shell: bash
env:
DISPLAY: ${{ inputs.DISPLAY }}
run: |
Xvfb :99 &
- name: Execute e2e smoke tests
shell: bash
id: e2e-tests
working-directory: ./packages/e2e-tests
env:
WALLET_1_PASSWORD: ${{ inputs.WALLET_PASSWORD }}
TEST_DAPP_URL: ${{ inputs.TEST_DAPP_URL }}
TAGS: ${{ inputs.TAGS }}
BROWSER: ${{ inputs.BROWSER }}
RUN: ${{ inputs.RUN }}
DISPLAY: ${{ inputs.DISPLAY }}
run: yarn wdio run wdio.conf.${{ inputs.BROWSER }}.ts --cucumberOpts.tags="@Smoke and not @Pending"

- name: Create allure properties
shell: bash
if: always()
working-directory: ./packages/e2e-tests/reports/allure/results
run: |
echo "
browser=${{ inputs.BROWSER }}
tags=${{ inputs.TAGS }}
platform=Linux
" > environment.properties
- name: Publish allure report to S3
uses: andrcuns/allure-publish-action@v2.4.0
if: always()
env:
GITHUB_AUTH_TOKEN: ${{ inputs.GITHUB_TOKEN }}
AWS_ACCESS_KEY_ID: ${{ inputs.E2E_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ inputs.E2E_AWS_SECRET_ACCESS_KEY }}
with:
storageType: s3
resultsGlob: './packages/e2e-tests/reports/allure/results'
bucket: lace-e2e-test-results
prefix: 'smoke/linux/${{ inputs.BROWSER }}/${{ inputs.RUN }}'
copyLatest: true
ignoreMissingResults: true
updatePr: comment
baseUrl: 'https://${{ inputs.E2E_REPORTS_USER }}:${{ inputs.E2E_REPORTS_PASSWORD }}@${{ inputs.E2E_REPORTS_URL }}'

- name: Publish artifacts (logs, reports, screenshots)
uses: actions/upload-artifact@v4
if: always()
with:
name: test-artifacts
path: |
./packages/e2e-tests/screenshots
./packages/e2e-tests/logs
./packages/e2e-tests/reports
retention-days: 5
14 changes: 14 additions & 0 deletions .github/actions/test/unit/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: unit
description: Execute unit tests

runs:
using: 'composite'

steps:
- name: Unit tests
run: yarn test
shell: bash
env:
AVAILABLE_CHAINS: 'Preprod,Preview,Mainnet'
DEFAULT_CHAIN: 'Preprod'
NODE_OPTIONS: '--max_old_space_size=8192'
37 changes: 37 additions & 0 deletions .github/workflows/chromatic-core.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Chromatic deploy packages/core

on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
paths:
- packages/core/**
push:
paths:
- packages/core/**
branches:
- main

jobs:
chromatic-deployment:
if: github.event.pull_request.draft == false
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Node.js and install dependencies
uses: ./.github/actions/install
with:
WALLET_PASSWORD: ${{ secrets.WALLET_PASSWORD_TESTNET }}

- name: Build
run: yarn workspaces foreach -Rpt -v --from '@lace/core' run build

- name: Chromatic packages-core
uses: ./.github/actions/chromatic
with:
DIR: packages/core
NAME: packages-core
TOKEN: ${{ secrets.CHROMATIC_LACE_CORE_TOKEN }}

0 comments on commit 31e15f9

Please sign in to comment.