Skip to content

Commit

Permalink
added build for MacOS-12; added store on wdio-electron custom api; si…
Browse files Browse the repository at this point in the history
…mplified test's setup
  • Loading branch information
qlrd committed Aug 6, 2023
1 parent 46cd15c commit 39b3169
Show file tree
Hide file tree
Showing 8 changed files with 267 additions and 286 deletions.
103 changes: 103 additions & 0 deletions .github/workflows/build-mac-dmg.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: Build electron application as dmg package on MacOS

on:
workflow_call:
secrets:
token:
required: true

jobs:

build-macos-12:
runs-on: macos-12

steps:

- name: Checkout Git repository
uses: actions/checkout@v3

- name: Install node
uses: actions/setup-node@v3
with:
node-version: 18

- name: Variables helpers
id: setup
run: |
KRUX_VERSION=`node -e "console.log(require('./package.json').version)"`
echo "app-version=$KRUX_VERSION" >> $GITHUB_OUTPUT
KRUX_NAME=krux-installer_$KRUX_VERSION
echo "app-name=$KRUX_NAME" >> $GITHUB_OUTPUT
echo "::group::Variables"
echo "app-version=$KRUX_VERSION"
echo "app-name=$KRUX_NAME"
echo "::endgroup::"
- name: Install dependencies
run: yarn install

#- name: Install chromedriver
#env:
#CHROMEDRIVER_VERSION: '114.0.5735.90'
#ZIPFILE: 'chromedriver_mac64.zip'
#DESTDIR: './node_modules/chromedriver/bin'
#ZIPURI: 'https://chromedriver.storage.googleapis.com'
#run: |
#curl -o ${TMPDIR}${ZIPFILE} $ZIPURI/$CHROMEDRIVER_VERSION/$ZIPFILE
#unzip -o ${TMPDIR}${ZIPFILE} -d $DESTDIR

#- name: List chromedriver binaries
#run: ls -la node_modules/chromedriver/bin

#- name: Pre-test chromedriver
#run: ./node_modules/chromedriver/bin/chromedriver --version

- name: Build electron app
env:
GH_TOKEN: ${{ secrets.token }}
run: yarn run build --macos dmg

- name: Hash electron app
uses: qlrd/sha256sum-action@v2
with:
working-directory: ./release/${{ steps.setup.outputs.app-version }}
file: ${{ steps.setup.outputs.app-name }}.dmg
ext: sha256.txt

- name: List release files
run: |
echo "::group::Release files"
ls -la release/${{ steps.setup.outputs.app-version }}
echo "::endgroup::"
echo "::group::Unpacked files"
ls -la release/${{ steps.setup.outputs.app-version }}/mac
echo "::endgroup::"
echo "::group::Unpacked .app directory"
ls -la release/${{ steps.setup.outputs.app-version }}/mac/krux-installer.app
echo "::endgroup::"
echo "::group::Unpacked .app/Contents directory"
ls -la release/${{ steps.setup.outputs.app-version }}/mac/krux-installer.app/Contents
echo "::endgroup::"
echo "::group::Unpacked .app/Contents/Frameworks directory"
ls -la release/${{ steps.setup.outputs.app-version }}/mac/krux-installer.app/Contents/Frameworks
echo "::endgroup::"
echo "::group::Unpacked .app/Contents/MacOS directory"
ls -la release/${{ steps.setup.outputs.app-version }}/mac/krux-installer.app/Contents/MacOS
echo "::endgroup::"
echo "::group::Unpacked .app/Contents/Resources directory"
ls -la release/${{ steps.setup.outputs.app-version }}/mac/krux-installer.app/Contents/Resources
echo "::endgroup::"
- name: E2E test electron app
env:
DEBUG: 'krux:*'
run: ./node_modules/.bin/wdio run wdio.conf.mts

- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ runner.os }}-${{ steps.setup.outputs.app-name }}-dmg
retention-days: 5
path: |
release/${{ steps.setup.outputs.app-version }}/${{ steps.setup.outputs.app-name }}.dmg
release/${{ steps.setup.outputs.app-version }}/${{ steps.setup.outputs.app-name }}.dmg.sha256.txt
5 changes: 5 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,8 @@ jobs:
uses: ./.github/workflows/build-windows-nsis.yml
secrets:
token: ${{ secrets.github_token }}

build-mac-dmg:
uses: ./.github/workflows/build-mac-dmg.yml
secrets:
token: ${{ secrets.github_token }}
12 changes: 11 additions & 1 deletion electron/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,17 @@ kruxInstaller.start(async ({ app, win, ipcMain}) => {
ipcMain.handle('wdio-electron', (_events, ...args) => {
return {
appData: app.getPath('appData'),
documents: app.getPath('documents')
documents: app.getPath('documents'),
store: {
appVersion: store.get('appVersion'),
resources: store.get('resources'),
os: store.get('os'),
versions: store.get('versions'),
version: store.get('version'),
device: store.get('device'),
sdcard: store.get('sdcard'),
showFlash: store.get('showFlash')
}
}
})
} else {
Expand Down
211 changes: 0 additions & 211 deletions test/e2e/specs/000.config.spec.ts

This file was deleted.

52 changes: 52 additions & 0 deletions test/e2e/specs/000.create-config.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
const { readdir, readFile } = require('fs/promises')
const { join } = require('path')
const expectChai = require('chai').expect
const { browser } = require('@wdio/globals')
const { describe, it } = require('mocha')
const { version } = require('../../../package.json')

describe('KruxInstaller configuration', () => {

it('should \'appData\' path exist with \'krux-installer\' directory', async () => {
try {
const api = await browser.electron.api() as Record<string, string>
const list = await readdir(api.appData)
expectChai(list.includes('krux-installer')).to.be.true
} catch (error) {
console.log(error)
}
})

it('should \'documents\' path exist with \'krux-installer\' directory', async () => {
try {
const api = await browser.electron.api() as Record<string, string>
const list = await readdir(api.documents)
expectChai(list.includes('krux-installer')).to.be.true
} catch (error) {
console.log(error)
}
})

it('should \'config.json\' file exists inside \'krux-installer\' directory', async () => {
try {
const api = await browser.electron.api() as Record<string, string>
const dir = join(api.appData, 'krux-installer')
const list = await readdir(dir)
expectChai(list.includes('config.json')).to.be.true
} catch (error) {
console.log(error)
}
})

it('should \'config.json\' be a readable string', async () => {
try {
const api = await browser.electron.api() as Record<string, string>
const filePath = join(api.appData, 'krux-installer', 'config.json')
const file = await readFile(filePath)
expectChai(file).to.be.a('string')
} catch (error) {
console.log(error)
}
})

})
Loading

0 comments on commit 39b3169

Please sign in to comment.