Skip to content

Commit

Permalink
feat(silo): Initial Silo scaffolding
Browse files Browse the repository at this point in the history
  • Loading branch information
ospencer committed Apr 21, 2024
1 parent 6e5b432 commit cdcfec4
Show file tree
Hide file tree
Showing 100 changed files with 5,216 additions and 34 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/build-js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,17 @@ jobs:
id: esy-cache
uses: actions/cache/restore@v3
with:
path: compiler/_export
key: ${{ runner.os }}-esy-${{ hashFiles('compiler/esy.lock/index.json') }}
# Not including all paths appears to cause cache misses, so we include silo cache as well
path: |
compiler/_export
silo/_export
key: ${{ runner.os }}-esy-${{ hashFiles('compiler/esy.lock/index.json', 'silo/esy.lock/index.json') }}

- name: Esy setup
# Don't crash the run if esy cache import fails - mostly happens on Windows
continue-on-error: true
run: |
npm run compiler prepare
npm run compiler install-dependencies
npm run compiler import-dependencies
# Don't build native executables, only the JS builds
Expand Down
22 changes: 18 additions & 4 deletions .github/workflows/build-native.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,17 @@ jobs:
id: esy-cache
uses: actions/cache/restore@v3
with:
path: compiler/_export
key: ${{ runner.os }}-esy-${{ hashFiles('compiler/esy.lock/index.json') }}
# Not including all paths appears to cause cache misses, so we include silo cache as well
path: |
compiler/_export
silo/_export
key: ${{ runner.os }}-esy-${{ hashFiles('compiler/esy.lock/index.json', 'silo/esy.lock/index.json') }}

- name: Esy setup
# Don't crash the run if esy cache import fails - mostly happens on Windows
continue-on-error: true
run: |
npm run compiler prepare
npm run compiler install-dependencies
npm run compiler import-dependencies
- name: Build compiler
Expand All @@ -72,11 +75,15 @@ jobs:
# Upload the artifacts before we run the tests so we
# can download to debug if tests fail in a weird way
- name: Tar native compiler artifacts
working-directory: ./cli/bin
run: tar -cvf ../../native_artifacts.tar *.exe

- name: Upload native compiler artifacts
uses: actions/upload-artifact@v3
with:
name: native-build-artifacts-${{ runner.os }}-${{ runner.arch }}
path: cli/bin/*.exe
path: ./native_artifacts.tar

- name: Run tests
run: |
Expand Down Expand Up @@ -120,3 +127,10 @@ jobs:
grain format stdlib -o stdlib
grain format compiler/test/stdlib -o compiler/test/stdlib
git diff --exit-code --name-only
silo:
name: Silo
uses: ./.github/workflows/silo.yml
needs: build
with:
os: ${{ inputs.os }}
11 changes: 8 additions & 3 deletions .github/workflows/dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ jobs:
id: esy-cache
uses: actions/cache@v3
with:
path: compiler/_export
key: ${{ runner.os }}-esy-${{ hashFiles('compiler/esy.lock/index.json') }}
path: |
compiler/_export
silo/_export
key: ${{ runner.os }}-esy-${{ hashFiles('compiler/esy.lock/index.json', 'silo/esy.lock/index.json') }}
lookup-only: true

# We only need to setup node & npm dependencies if we don't have an esy cache because
Expand All @@ -42,6 +44,9 @@ jobs:
- name: Build esy dependencies
if: steps.esy-cache.outputs.cache-hit != 'true'
run: |
npm run compiler prepare
npm run compiler install-dependencies
npm run compiler build-dependencies
npm run compiler export-dependencies
npm run silo install-dependencies
npm run silo build-dependencies
npm run silo export-dependencies
92 changes: 92 additions & 0 deletions .github/workflows/silo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: (native) Silo build and test

on:
workflow_call:
inputs:
os:
description: Operating system to run CI on
type: string
required: true

jobs:
build:
name: (native) Silo build and test
runs-on: ${{ inputs.os }}

steps:
- name: Checkout project
uses: actions/checkout@v3

- name: Setup node.js
uses: actions/setup-node@v3.6.0
with:
node-version: ">=18.15 <19"
check-latest: true
cache: "npm"

- name: Install npm dependencies
run: |
npm ci
- name: Esy cache
id: esy-cache
uses: actions/cache/restore@v3
with:
# Not including all paths appears to cause cache misses, so we include the compiler cache as well
path: |
compiler/_export
silo/_export
key: ${{ runner.os }}-esy-${{ hashFiles('compiler/esy.lock/index.json', 'silo/esy.lock/index.json') }}

- name: Esy setup
# Don't crash the run if esy cache import fails - mostly happens on Windows
continue-on-error: true
run: |
npm run silo install-dependencies
npm run silo import-dependencies
- name: Build silo
run: |
npm run silo build
- name: Download grainc artifacts
uses: actions/download-artifact@v3
with:
name: native-build-artifacts-${{ runner.os }}-${{ runner.arch }}
path: bin

- name: Untar download
working-directory: bin
run: |
tar -xvf native_artifacts.tar
- name: Copy silo executable
run: |
cp cli/bin/silo.exe bin
- name: Add artifacts to PATH (windows)
if: ${{ inputs.os == 'windows-latest' }}
working-directory: bin
run: pwd | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append

- name: Add artifacts to PATH (unix)
if: ${{ inputs.os != 'windows-latest' }}
working-directory: bin
run: |
mv grainc.exe grainc
mv graindoc.exe graindoc
mv grainformat.exe grainformat
mv grainlsp.exe grainlsp
mv silo.exe silo
echo $(pwd) >> $GITHUB_PATH
- name: Run tests
run: |
npm run silo test
# Check formatting last because building is more important
- name: (silo) Check formatting
if: inputs.os != 'windows-latest'
run: |
npm run silo check-format
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,6 @@ cli/bin/grainformat.exe
cli/bin/grainformat.bc.js
cli/bin/grainlsp.exe
cli/bin/grainlsp.bc.js
cli/bin/silo.exe

.DS_Store
2 changes: 1 addition & 1 deletion compiler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"scripts": {
"link": "npm link",
"clean": "esy clean",
"prepare": "esy install",
"install-dependencies": "esy install",
"prebuild": "npm run clean --workspace=@grain/cli",
"build": "esy",
"postbuild": "esy copy:exe",
Expand Down
90 changes: 68 additions & 22 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"workspaces": [
"cli",
"stdlib",
"compiler"
"compiler",
"silo"
],
"engines": {
"node": ">=18.15"
Expand All @@ -17,6 +18,7 @@
"cli": "npm run --workspace=@grain/cli --",
"compiler": "npm run --workspace=@grain/compiler --",
"stdlib": "npm run --workspace=@grain/stdlib --",
"silo": "npm run --workspace=@grain/silo --",
"postcompiler": "npm run stdlib clean"
}
}
3 changes: 3 additions & 0 deletions silo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
_esy
node_modules
test/output
10 changes: 10 additions & 0 deletions silo/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"files.associations": {
"*.dyp": "ocaml.ocamllex",
"CODEOWNERS": "ignore"
},
"ocaml.sandbox": {
"kind": "esy",
"root": "${workspaceFolder:silo}"
}
}
Loading

0 comments on commit cdcfec4

Please sign in to comment.