Skip to content

Commit

Permalink
Set up CI workflow.
Browse files Browse the repository at this point in the history
  • Loading branch information
CXuesong committed Jul 14, 2024
1 parent 8def294 commit 4fb7593
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 2 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/build-packages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Build workspace packages

on:
push:
branches:
- main
paths-ignore:
- /*.md
pull_request:
branches:
- main
paths-ignore:
- /*.md
schedule:
- cron: 7 0 * * MON

jobs:
build_linux:
name: Build workspace packages (Linux)
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Restore workspace
shell: pwsh
run: ./scripts/Restore-Workspace.ps1
- name: Build workspace
shell: pwsh
run: ./scripts/Build-Workspace.ps1
- name: Analyze workspace
shell: pwsh
run: ./scripts/Analyze-Workspace.ps1
- name: Collect artifacts
if: always()
shell: pwsh
run: ./scripts/Collect-Artifacts.ps1 -ArtifactPath build-artifacts
- uses: actions/upload-artifact@v2
if: always()
with:
name: BuildArtifacts-Linux-Release
path: ./build-artifacts
10 changes: 8 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"eslint.experimental.useFlatConfig": true,
"eslint.useFlatConfig": true,
"eslint.workingDirectories": [
{
"mode": "auto"
Expand All @@ -14,5 +14,11 @@
},
"[javascript]": {
"editor.tabSize": 2
}
},
"[yaml]": {
"editor.tabSize": 2
},
"[github-actions-workflow]": {
"editor.tabSize": 2
},
}
4 changes: 4 additions & 0 deletions scripts/Analyze-Workspace.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Import-Module $PSScriptRoot/Utilities.psm1

yarn g:lint
checkLastExitCode
4 changes: 4 additions & 0 deletions scripts/Build-Workspace.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Import-Module $PSScriptRoot/Utilities.psm1

yarn g:build:prod
checkLastExitCode
16 changes: 16 additions & 0 deletions scripts/Collect-Artifacts.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<#
.SYNOPSIS
Collects built packages as artifacts.
Assumes $PWD is the repo root.
#>
param (
[Parameter(Mandatory = $true)]
[string]$ArtifactPath
)

Import-Module $PSScriptRoot/Utilities.psm1

$ArtifactPath = (New-Item $ArtifactPath -ItemType Directory -Force).FullName

Write-Host "ArtifactPath=$ArtifactPath"
Copy-Item ./packages $ArtifactPath/
5 changes: 5 additions & 0 deletions scripts/Restore-Workspace.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Import-Module $PSScriptRoot/Utilities.psm1

# Assumes $PWD is repo root
yarn install --frozen-lockfile
checkLastExitCode
10 changes: 10 additions & 0 deletions scripts/Utilities.psm1
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# TODO
# https://github.com/actions/runner-images/issues/8900
# PSNativeCommandUseErrorActionPreference = $true

function checkLastExitCode() {
if ($LASTEXITCODE) {
Write-Error "Command exit code indicates failure: $LASTEXITCODE"
Exit $LASTEXITCODE
}
}

0 comments on commit 4fb7593

Please sign in to comment.