diff --git a/.github/actions/build/action.yml b/.github/actions/build/action.yml new file mode 100644 index 000000000..1ba5988f0 --- /dev/null +++ b/.github/actions/build/action.yml @@ -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 diff --git a/.github/actions/install-code/action.yml b/.github/actions/install-code/action.yml index aa435c374..b8aea03b4 100644 --- a/.github/actions/install-code/action.yml +++ b/.github/actions/install-code/action.yml @@ -1,15 +1,57 @@ name: Install VS Code -description: Set up VS Code (Linux-only) +description: Set up VS Code author: Marten Lohstroh 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 \ No newline at end of file + 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 diff --git a/.github/actions/uninstall-dependencies/action.yml b/.github/actions/uninstall-dependencies/action.yml new file mode 100644 index 000000000..925b4a423 --- /dev/null +++ b/.github/actions/uninstall-dependencies/action.yml @@ -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' }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4a0bef235..631a5eedc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/lingua-franca b/lingua-franca index c5f1c7488..c56002272 160000 --- a/lingua-franca +++ b/lingua-franca @@ -1 +1 @@ -Subproject commit c5f1c74885af6857dc99f09c756b738045547da5 +Subproject commit c560022720dbba0478f41bec5a11f9ee04ee378b