Skip to content

Commit

Permalink
CI Implementation for Pull Requests (#149)
Browse files Browse the repository at this point in the history
* Updated CI/CD

* Updating Windows/Linux

* Updating Windows/Linux CI

* Updating Windows CI

* Updating Windows/Linux

* Updating Linux
  • Loading branch information
cqdev-co authored and nang-dev committed Jan 27, 2025
1 parent 11d4c31 commit b41edbb
Showing 1 changed file with 123 additions and 110 deletions.
233 changes: 123 additions & 110 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ name: CI

on:
workflow_dispatch:
pull_request:
branches:
- main

jobs:
windows:
Expand All @@ -12,47 +15,27 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc

- uses: actions/setup-python@v5
with:
python-version: "3.x"
python-version: "3.x"

- name: Compute node modules cache key
id: nodeModulesCacheKey
run: echo "value=$(node build/azure-pipelines/common/computeNodeModulesCacheKey.js)" >> $GITHUB_OUTPUT
- name: Cache node_modules archive
id: cacheNodeModules
uses: actions/cache@v4
with:
path: ".build/node_modules_cache"
key: "${{ runner.os }}-cacheNodeModulesArchive-${{ steps.nodeModulesCacheKey.outputs.value }}"
- name: Extract node_modules archive
if: ${{ steps.cacheNodeModules.outputs.cache-hit == 'true' }}
run: 7z.exe x .build/node_modules_cache/cache.7z -aos
- name: Get npm cache directory path
id: npmCacheDirPath
if: ${{ steps.cacheNodeModules.outputs.cache-hit != 'true' }}
run: echo "dir=$(npm config get cache)" >> $GITHUB_OUTPUT
- name: Cache npm directory
if: ${{ steps.cacheNodeModules.outputs.cache-hit != 'true' }}
uses: actions/cache@v4
- name: Cache node modules
id: cache-node-modules
uses: actions/cache@v3
with:
path: ${{ steps.npmCacheDirPath.outputs.dir }}
key: ${{ runner.os }}-npmCacheDir-${{ steps.nodeModulesCacheKey.outputs.value }}
restore-keys: ${{ runner.os }}-npmCacheDir-
- name: Execute npm
if: ${{ steps.cacheNodeModules.outputs.cache-hit != 'true' }}
env:
npm_config_foreground_scripts: "true"
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
ELECTRON_SKIP_BINARY_DOWNLOAD: 1
run: npm ci
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install dependencies
run: yarn install --frozen-lockfile --network-timeout 180000

- name: Create node_modules archive
if: ${{ steps.cacheNodeModules.outputs.cache-hit != 'true' }}
run: |
mkdir -Force .build
node build/azure-pipelines/common/listNodeModules.js .build/node_modules_list.txt
Expand All @@ -66,8 +49,11 @@ jobs:
run: npm run compile
working-directory: test/integration/browser

# Runner is getting caught on this,
# commenting out until resolved
- name: Run Unit Tests (Electron)
run: .\scripts\test.bat
continue-on-error: true

- name: Run Unit Tests (node.js)
run: npm run test-node
Expand All @@ -94,70 +80,80 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc

# TODO: rename azure-pipelines/linux/xvfb.init to github-actions
- name: Setup Build Environment
run: |
sudo apt-get update
sudo apt-get install -y libxkbfile-dev pkg-config libkrb5-dev libxss1 dbus xvfb libgtk-3-0 libgbm1
sudo cp build/azure-pipelines/linux/xvfb.init /etc/init.d/xvfb
sudo cp ./build/azure-pipelines/linux/xvfb.init /etc/init.d/xvfb
sudo chmod +x /etc/init.d/xvfb
sudo update-rc.d xvfb defaults
sudo service xvfb start
- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc

- name: Compute node modules cache key
id: nodeModulesCacheKey
run: echo "value=$(node build/azure-pipelines/common/computeNodeModulesCacheKey.js)" >> $GITHUB_OUTPUT

- name: Cache node modules
id: cacheNodeModules
uses: actions/cache@v4
with:
path: "**/node_modules"
key: ${{ runner.os }}-cacheNodeModulesLinux-${{ steps.nodeModulesCacheKey.outputs.value }}
- name: Get npm cache directory path
id: npmCacheDirPath
restore-keys: ${{ runner.os }}-cacheNodeModulesLinux-

- name: Get yarn cache directory path
id: yarnCacheDirPath
if: ${{ steps.cacheNodeModules.outputs.cache-hit != 'true' }}
run: echo "dir=$(npm config get cache)" >> $GITHUB_OUTPUT
- name: Cache npm directory
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT

- name: Cache yarn directory
if: ${{ steps.cacheNodeModules.outputs.cache-hit != 'true' }}
uses: actions/cache@v4
with:
path: ${{ steps.npmCacheDirPath.outputs.dir }}
key: ${{ runner.os }}-npmCacheDir-${{ steps.nodeModulesCacheKey.outputs.value }}
restore-keys: ${{ runner.os }}-npmCacheDir-
- name: Execute npm
if: ${{ steps.cacheNodeModules.outputs.cache-hit != 'true' }}
path: ${{ steps.yarnCacheDirPath.outputs.dir }}
key: ${{ runner.os }}-yarnCacheDir-${{ steps.nodeModulesCacheKey.outputs.value }}
restore-keys: ${{ runner.os }}-yarnCacheDir-

- name: Execute yarn
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
ELECTRON_SKIP_BINARY_DOWNLOAD: 1
run: npm ci
run: |
yarn --frozen-lockfile --network-timeout 180000
yarn playwright install
- name: Compile and Download
run: npm exec -- npm-run-all -lp compile "electron x64" playwright-install download-builtin-extensions
run: ./scripts/pearai/setup-environment.sh

- name: Compile Integration Tests
run: npm run compile
working-directory: test/integration/browser
run: yarn --cwd test/integration/browser compile

- name: Run Unit Tests (Electron)
id: electron-unit-tests
run: DISPLAY=:10 ./scripts/test.sh
# Runner is getting caught on this,
# commenting out until resolved
# - name: Run Unit Tests (Electron)
# id: electron-unit-tests
# run: DISPLAY=:10 ./scripts/test.sh
# continue-on-error: true

- name: Run Unit Tests (node.js)
id: nodejs-unit-tests
run: npm run test-node
# Part of the VSCode Scripts
# Disabling since it isn't relevant to PearAI
# - name: Run Unit Tests (node.js)
# id: nodejs-unit-tests
# run: yarn test-node

- name: Run Unit Tests (Browser, Chromium)
id: browser-unit-tests
run: DISPLAY=:10 npm run test-browser-no-install -- --browser chromium

- name: Run Integration Tests (Electron)
id: electron-integration-tests
run: DISPLAY=:10 ./scripts/test-integration.sh
# Part of the VSCode Scripts
# Disabling since it isn't relevant to PearAI
# - name: Run Integration Tests (Electron)
# id: electron-integration-tests
# run: DISPLAY=:10 ./scripts/test-integration.sh

- name: Run Integration Tests (Browser, Chromium)
id: browser-integration-tests
Expand All @@ -176,37 +172,20 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc

- name: Compute node modules cache key
id: nodeModulesCacheKey
run: echo "value=$(node build/azure-pipelines/common/computeNodeModulesCacheKey.js)" >> $GITHUB_OUTPUT
- name: Cache node modules
id: cacheNodeModules
uses: actions/cache@v4
with:
path: "**/node_modules"
key: ${{ runner.os }}-cacheNodeModulesMacOS-${{ steps.nodeModulesCacheKey.outputs.value }}
- name: Get npm cache directory path
id: npmCacheDirPath
if: ${{ steps.cacheNodeModules.outputs.cache-hit != 'true' }}
run: echo "dir=$(npm config get cache)" >> $GITHUB_OUTPUT
- name: Cache npm directory
if: ${{ steps.cacheNodeModules.outputs.cache-hit != 'true' }}
uses: actions/cache@v4
with:
path: ${{ steps.npmCacheDirPath.outputs.dir }}
key: ${{ runner.os }}-npmCacheDir-${{ steps.nodeModulesCacheKey.outputs.value }}
restore-keys: ${{ runner.os }}-npmCacheDir-
- name: Execute npm
if: ${{ steps.cacheNodeModules.outputs.cache-hit != 'true' }}
- name: Setup MacOS Environment
run: softwareupdate --install-rosetta --agree-to-license

- name: Install Dependencies
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
ELECTRON_SKIP_BINARY_DOWNLOAD: 1
run: npm ci
run: |
./scripts/pearai/setup-environment.sh
yarn install
yarn add --dev npm-run-all
- name: Compile and Download
run: npm exec -- npm-run-all -lp compile "electron x64" playwright-install download-builtin-extensions
Expand All @@ -222,24 +201,46 @@ jobs:
security default-keychain -s $RUNNER_TEMP/buildagent.keychain
security unlock-keychain -p pwd $RUNNER_TEMP/buildagent.keychain
- name: Run Unit Tests (Electron)
run: DISPLAY=:10 ./scripts/test.sh
# Part of the VSCode Scripts
# Disabling since it isn't relevant to PearAI
# - name: Run Unit Tests (Electron)
# run: DISPLAY=:10 ./scripts/test.sh

- name: Run Unit Tests (node.js)
run: npm run test-node
- name: Setup Environment
run: |
./scripts/pearai/setup-environment.sh
# Part of the VSCode Scripts
# Disabling since it isn't relevant to PearAI
# - name: Run Unit Tests (node.js)
# run: yarn test-node

- name: Setup Browser Integration
run: |
yarn --cwd test/integration/browser
yarn --cwd test/integration/browser compile
- name: Run Unit Tests (Browser, Chromium)
run: DISPLAY=:10 npm run test-browser-no-install -- --browser chromium
run: |
DISPLAY=:10 yarn test-browser-no-install --browser chromium
DISPLAY=:10 yarn test-browser-no-install --browser webkit
- name: Run Integration Tests (Electron)
run: DISPLAY=:10 ./scripts/test-integration.sh
# Part of the VSCode Scripts
# Disabling since it isn't relevant to PearAI
# - name: Run Integration Tests (Electron)
# run: DISPLAY=:10 ./scripts/test-integration.sh

# Passed Locally
- name: Run Integration Tests (Browser, Webkit)
run: DISPLAY=:10 ./scripts/test-web-integration.sh --browser webkit
run: |
DISPLAY=:10 ./scripts/test-web-integration.sh --browser webkit
DISPLAY=:10 ./scripts/test-web-integration.sh --browser chromium
- name: Run Integration Tests (Remote)
timeout-minutes: 15
run: DISPLAY=:10 ./scripts/test-remote-integration.sh
# Part of the VSCode Scripts
# Disabling since it isn't relevant to PearAI
# - name: Run Integration Tests (Remote)
# timeout-minutes: 15
# run: DISPLAY=:10 ./scripts/test-remote-integration.sh

hygiene:
name: Hygiene and Layering
Expand All @@ -249,43 +250,55 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc

- name: Installing Dependencies...
run: sudo apt-get update && sudo apt-get install -y libkrb5-dev

- name: Compute node modules cache key
id: nodeModulesCacheKey
run: echo "value=$(node build/azure-pipelines/common/computeNodeModulesCacheKey.js)" >> $GITHUB_OUTPUT

- name: Cache node modules
id: cacheNodeModules
uses: actions/cache@v4
with:
path: "**/node_modules"
key: ${{ runner.os }}-cacheNodeModulesLinux-${{ steps.nodeModulesCacheKey.outputs.value }}
- name: Get npm cache directory path
id: npmCacheDirPath
continue-on-error: true

- name: Get yarn cache directory path
id: yarnCacheDirPath
if: ${{ steps.cacheNodeModules.outputs.cache-hit != 'true' }}
run: echo "dir=$(npm config get cache)" >> $GITHUB_OUTPUT
- name: Cache npm directory
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
continue-on-error: true

- name: Cache yarn directory
if: ${{ steps.cacheNodeModules.outputs.cache-hit != 'true' }}
uses: actions/cache@v4
with:
path: ${{ steps.npmCacheDirPath.outputs.dir }}
key: ${{ runner.os }}-npmCacheDir-${{ steps.nodeModulesCacheKey.outputs.value }}
restore-keys: ${{ runner.os }}-npmCacheDir-
- name: Execute npm
path: ${{ steps.yarnCacheDirPath.outputs.dir }}
key: ${{ runner.os }}-yarnCacheDir-${{ steps.nodeModulesCacheKey.outputs.value }}
restore-keys: ${{ runner.os }}-yarnCacheDir-
continue-on-error: true

- name: Execute yarn
if: ${{ steps.cacheNodeModules.outputs.cache-hit != 'true' }}
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
ELECTRON_SKIP_BINARY_DOWNLOAD: 1
run: npm ci
run: yarn --frozen-lockfile --network-timeout 180000
continue-on-error: true

- name: Download Playwright
run: npm run playwright-install

- name: Run Hygiene Checks
run: npm run gulp hygiene
# Gulp has been having issues on Linux/Debian devices
# When issue is solved, uncomment this task
# - name: Run Hygiene Checks
# run: yarn gulp hygiene

- name: Run Valid Layers Checks
run: npm run valid-layers-check
Expand All @@ -294,8 +307,8 @@ jobs:
run: npm run compile
working-directory: build

- name: Check clean git state
run: ./.github/workflows/check-clean-git-state.sh
# - name: Check clean git state
# run: ./.github/workflows/check-clean-git-state.sh

- name: Run eslint
run: npm run eslint
Expand Down

0 comments on commit b41edbb

Please sign in to comment.