Skip to content

Commit

Permalink
[CI] Set up tests in CI.
Browse files Browse the repository at this point in the history
  • Loading branch information
petervdonovan committed May 25, 2022
1 parent 16ae135 commit 080e397
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 18 deletions.
14 changes: 14 additions & 0 deletions .github/actions/build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Build
description: Set up the repository, install the dependencies required to build the extension, and build the extension.

runs:
using: "composite"
steps:
- name: Prepare LF build environment
uses: ./lingua-franca/.github/actions/prepare-build-env
- name: Install VS Code
uses: ./.github/actions/install-code
- name: Build the VS Code extension
# TODO: Cache the JARs and node_modules, hashing by LF ref and package.json.
run: npm install
shell: bash
54 changes: 48 additions & 6 deletions .github/actions/install-code/action.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,57 @@
name: Install VS Code
description: Set up VS Code (Linux-only)
description: Set up VS Code
author: Marten Lohstroh <marten@berkeley.edu>

runs:
using: composite
steps:
- name: Install VS Code
- name: Install VS Code (Linux)
if: ${{ runner.os == 'Linux' }}
run: |
sudo apt-get install wget gpg
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg
sudo install -o root -g root -m 644 packages.microsoft.gpg /etc/apt/trusted.gpg.d/
sudo sh -c 'echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/trusted.gpg.d/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" > /etc/apt/sources.list.d/vscode.list'
rm -f packages.microsoft.gpg
sudo apt install apt-transport-https
sudo apt update
sudo apt install software-properties-common apt-transport-https wget
wget -q https://packages.microsoft.com/keys/microsoft.asc -O- | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main"
sudo apt install code
shell: bash
shell: bash
- name: Install VS Code (MacOS)
if: ${{ runner.os == 'macOS' }}
run: brew install --cask visual-studio-code
shell: bash
- name: Install VS Code (Windows)
if: ${{ runner.os == 'Windows' }}
run: |
choco install vscode
refreshenv
echo "Appending to PATH..."
Add-Content "GITHUB_PATH" "C:\Program Files\Microsoft VS Code\"
Add-Content "Path" "C:\Program Files\Microsoft VS Code\"
[Environment]::SetEnvironmentVariable(
"Path",
[Environment]::GetEnvironmentVariable("Path", [EnvironmentVariableTarget]::Machine) + ";C:\Program Files\Microsoft VS Code\",
[EnvironmentVariableTarget]::Machine)
[Environment]::SetEnvironmentVariable(
"GITHUB_PATH",
[Environment]::GetEnvironmentVariable("Path", [EnvironmentVariableTarget]::Machine) + ";C:\Program Files\Microsoft VS Code\",
[EnvironmentVariableTarget]::Machine)
Add-Content "GITHUB_PATH" "C:\ProgramData\chocolatey\lib\vscode"
Add-Content "Path" "C:\ProgramData\chocolatey\lib"
[Environment]::SetEnvironmentVariable(
"Path",
[Environment]::GetEnvironmentVariable("Path", [EnvironmentVariableTarget]::Machine) + ";C:\ProgramData\chocolatey\lib\vscode",
[EnvironmentVariableTarget]::Machine)
echo "PATH is now:"
echo $env:GITHUB_PATH
code
vscode
visualstudiocode
C:\ProgramData\chocolatey\lib\vscode
"C:\Program Files\Microsoft VS Code\code.exe"
gcm code
where code
dir "C:\Program Files\Microsoft VS Code\"
dir "C:\ProgramData\chocolatey\lib\vscode"
shell: PowerShell
28 changes: 28 additions & 0 deletions .github/actions/uninstall-dependencies/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Uninstall dependencies
description: Uninstall dependencies whose presence the VS Code extension may check for.

runs:
steps:
- name: Uninstall packages
uses: ./lingua-franca/.github/actions/uninstall-dependencies
with:
platform: ${{ matrix.platform }}
- name: Uninstall packages Ubuntu
run: |
sudo apt-get remove gcc
sudo apt-get remove g++
rm -rf ${JAVA_HOME}
if: ${{ platform == 'Linux' }}
- name: Uninstall packages MacOS
run: |
brew uninstall --ignore-dependencies g++
brew uninstall --ignore-dependencies clang-*
rm -rf ${JAVA_HOME}
if: ${{ runner.os == 'macOS' }}
- name: Uninstall packages Windows
run: |
del "C:\ProgramData\Chocolatey\bin\g++.exe"
del "C:\Strawberry\c\bin\g++.exe"
del "C:\Program Files\LLVM\bin\clang++.exe"
del /s ${JAVA_HOME}
if: ${{ runner.os == 'Windows' }}
32 changes: 21 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,30 @@ on:
# Trigger this workflow also on pull_request events.
pull_request:

jobs:
build:
runs-on: ubuntu-latest
jobs:
test:
strategy:
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.platform }}
steps:
- name: Check out vscode-lingua-franca repository
uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0
- name: Prepare LF build environment
uses: ./lingua-franca/.github/actions/prepare-build-env
- name: Install VS Code
uses: ./.github/actions/install-code
- name: Build, deploy, and test the VS Code extension
run: |
npm install
npm run test
- uses: lf-lang/vscode-lingua-franca/.github/actions/build@check-versions
- name: Run tests
run: npm run test
test-dependencies-missing:
strategy:
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.platform }}
steps:
- uses: lf-lang/vscode-lingua-franca/.github/actions/build@check-versions
# Uninstall operations are needed because we must test that the VS Code extension detects
# which tools are present and responds appropriately.
- uses: ./.github/actions/uninstall-dependencies
- name: Run tests
run: npm run test-dependencies-missing
2 changes: 1 addition & 1 deletion lingua-franca
Submodule lingua-franca updated 675 files

0 comments on commit 080e397

Please sign in to comment.