From e30143f3923b3ccf091c039a8a879573aae2434a Mon Sep 17 00:00:00 2001 From: Nils Hjelte Date: Fri, 29 Sep 2023 10:40:09 +0200 Subject: [PATCH] CI Artifacts (#1) --- .github/workflows/build-and-test.yml | 218 ++++++++++++++++++ .github/workflows/publish-release-version.yml | 32 +++ .gitmodules | 12 +- Swifty-LLVM | 1 - build-and-install-vscode-extension.sh | 14 ++ build-vs-code-extension.sh | 13 -- hylo-lsp-vs-code | 1 - hylo-vscode-extension | 1 + 8 files changed, 268 insertions(+), 24 deletions(-) create mode 100644 .github/workflows/build-and-test.yml create mode 100644 .github/workflows/publish-release-version.yml delete mode 160000 Swifty-LLVM create mode 100755 build-and-install-vscode-extension.sh delete mode 100755 build-vs-code-extension.sh delete mode 160000 hylo-lsp-vs-code create mode 160000 hylo-vscode-extension diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml new file mode 100644 index 0000000..15912af --- /dev/null +++ b/.github/workflows/build-and-test.yml @@ -0,0 +1,218 @@ +name: Build and test + +# README: +# +# The semantics for running shell commands in GitHub actions is non-obvious. Please read +# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsshell +# before modifying this file. Our strategy is to rely on the built-in (unspecified) shell, and +# explicitly set the shell settings we want (with `set -eo pipefail`) at the beginning of any +# bash script. For more information on these settings, see `man bash`. +# +# GitHub Actions files can be difficult to modify with confidence, because testing changes often +# requires pushing to a branch and running CI remotely. To make this process easier, consider +# the following: +# +# 1) Use Visual Studio Code with the GitHub Actions Extension (github.vscode-github-actions). +# This allows you to check the validity of your action schema and syntax without pushing to a +# branch. +# 2) Use https://github.com/nektos/act to run your CI steps locally. Note this will only work with +# steps run on Linux platforms, as `act` is implemented with Docker containers. + +on: + push: + branches: [ main ] + paths-ignore: + - "Docs/**" + - "**.md" + - "README.md" + - "LICENSE" + - ".gitignore" + pull_request: + branches: [ "**" ] + paths-ignore: + - "Docs/**" + - "**.md" + - "README.md" + - "LICENSE" + - ".gitignore" + +jobs: + # build-devcontainer-linux: + # name: "Devcontainer: ${{ matrix.host.os }}/${{ matrix.configuration }}" + # strategy: + # fail-fast: false + # matrix: + # host: [ + # { type: linux, os: ubuntu-latest, + # build-options: "-v --build-tests -Xswiftc -enable-testing", + # test-options: "-v --enable-code-coverage" + # } + # ] + # configuration: [ "debug", "release" ] + + # runs-on: ${{ matrix.host.os }} + # steps: + # - uses: actions/checkout@v3 + + # - uses: actions/cache@v3 + # with: + # path: .build + # key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }} + # restore-keys: | + # ${{ runner.os }}-spm- + + # - name: Build and Test + # uses: devcontainers/ci@v0.3 + # with: + # runCmd: | + # set -eo pipefail + # swift package resolve + # .build/checkouts/Swifty-LLVM/Tools/make-pkgconfig.sh llvm.pc + # export PKG_CONFIG_PATH=$PWD + # swift build -c ${{ matrix.configuration }} ${{ matrix.host.build-options }} + # swift test -c ${{ matrix.configuration }} ${{ matrix.host.test-options }} | + # tee testoutput.txt && ( + # (grep -q "[.']EndToEndTests[/. ]test_" testoutput.txt && grep -q "[.']HyloTests[/. ]test_" testoutput.txt) || + # (echo "error: generated tests failed to run; see + # https://github.com/apple/swift-package-manager/issues/6595" && false) ) + + # - name: Check code coverage + # uses: mattpolzin/swift-codecov-action@0.7.3 + # with: + # SORT_ORDER: +cov + # MINIMUM_COVERAGE: 84 + # CODECOV_JSON: .build/${{ matrix.configuration }}/codecov/*.json + + build-native-macos: + name: "Native: ${{ matrix.host.os }}/${{ matrix.configuration }}" + strategy: + fail-fast: false + matrix: + host: [ + { + type: macos, os: macos-13, + build-options: "-v --build-tests -Xswiftc -enable-testing", + # No coverage support on MacOS + test-options: "-v" + } + ] + swift: [ + { version: "5.9" } + ] + configuration: [ "debug" ] + # configuration: [ "debug", "release" ] + + runs-on: ${{ matrix.host.os }} + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + submodules: 'true' + + - name: Setup swift + uses: swift-actions/setup-swift@v1 + with: + swift-version: ${{ matrix.swift.version }} + + - run: swift --version + + - name: Setup LLVM + uses: KyleMayes/install-llvm-action@v1 + with: + version: "15.0" + + - run: llvm-config --version + + - name: Generate LLVM pkgconfig file + run: | + set -eo pipefail + cd hylo + swift package resolve + .build/checkouts/Swifty-LLVM/Tools/make-pkgconfig.sh llvm.pc + cat llvm.pc + + - name: Build (${{ matrix.configuration }}) + run: | + set -eo pipefail + export PKG_CONFIG_PATH=$PWD/hylo + swift build -c ${{ matrix.configuration }} ${{ matrix.host.build-options }} + + # - name: Test (${{ matrix.configuration }}) + # run: | + # set -eo pipefail + # export PKG_CONFIG_PATH=$PWD/hylo + # swift test -c ${{ matrix.configuration }} ${{ matrix.host.test-options }} | + # tee testoutput.txt && ( + # (grep -q "[.']EndToEndTests[/. ]test_" testoutput.txt && grep -q "[.']HyloTests[/. ]test_" testoutput.txt) || + # (echo "error: generated tests failed to run; see + # https://github.com/apple/swift-package-manager/issues/6595" && false) ) + + - uses: actions/setup-node@v3 + with: + node-version: 20 + + - name: Package VSCode extension (${{ matrix.configuration }}) + run: | + set -eo pipefail + BUILD_DIR=$(swift build -c ${{ matrix.configuration }} --show-bin-path) + mkdir -p hylo-vscode-extension/bin/mac/arm64 + cp -fv $BUILD_DIR/hylo-lsp-server hylo-vscode-extension/bin/mac/arm64 + cd hylo-vscode-extension + npm install + npm run vscode:package + + - name: Upload VSCode extension artifacts (${{ matrix.configuration }}) + uses: actions/upload-artifact@v3 + with: + name: vscode-extension-artifacts + path: | + hylo-vscode-extension/hylo-lang-*.vsix + dist + !dist/**/*.md + + # build-native-windows: + # name: "Native, no testing: windows-latest/release" + # strategy: + # fail-fast: false + # runs-on: windows-latest + # steps: + # - name: Setup swift + # uses: compnerd/gha-setup-swift@main + # with: + # branch: swift-5.8.1-release + # tag: 5.8.1-RELEASE + + # - uses: actions/checkout@v3 + + # - name: Swift version + # run: swift --version + + # - name: Set up LLVM 15.0.6 + # run: | + # curl.exe -L -O -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}"https://github.com/c3lang/win-llvm/releases/download/llvm_15_0_6/llvm-15.0.6-windows-x86-msvc17-msvcrt.7z + # 7z x llvm-15.0.6-windows-x86-msvc17-msvcrt.7z -oC:\ + # Add-Content $env:GITHUB_PATH 'C:\llvm-15.0.6-windows-x86-msvc17-msvcrt\bin' + + # - name: Copy LLVM's include and lib to include and lib folder of MSVC + # run: | + # xcopy c:\llvm-15.0.6-windows-x86-msvc17-msvcrt\include\*.* c:\program" "files\microsoft" "visual" "studio\2022\enterprise\vc\tools\msvc\${{ env.VCToolsVersion }}\include\ /s /h + # xcopy c:\llvm-15.0.6-windows-x86-msvc17-msvcrt\lib\*.* c:\program" "files\microsoft" "visual" "studio\2022\enterprise\vc\tools\msvc\${{ env.VCToolsVersion }}\lib\x64\ /s /h + + # - run: llvm-config --version + + # - name: Build support library + # run: clang -c ./Library/Hylo/LibC.c -o HyloLibC.lib + + # - name: Copy support library + # run: xcopy HyloLibC.lib c:\program" "files\microsoft" "visual" "studio\2022\enterprise\vc\tools\msvc\${{ env.VCToolsVersion }}\lib\x64\ + + # - name: Build (Release) + # id: build + # continue-on-error: true + # run: swift build -v -c release + + # - name: Retry on failure + # continue-on-error: false + # if: steps.build.outcome != 'success' + # run: swift build -v -c release + diff --git a/.github/workflows/publish-release-version.yml b/.github/workflows/publish-release-version.yml new file mode 100644 index 0000000..b5025ec --- /dev/null +++ b/.github/workflows/publish-release-version.yml @@ -0,0 +1,32 @@ +name: Publish release version + +on: + workflow_run: + workflows: ["Build and test"] + tags: ["v*.*.*"] + types: [completed] + +jobs: + publish-release: + strategy: + fail-fast: false + + matrix: + host: [ + { + type: macos, os: macos-13, + build-options: "-v --build-tests -Xswiftc -enable-testing", + # No coverage support on MacOS + test-options: "-v" + } + ] + + runs-on: ${{ matrix.host.os }} + steps: + # - uses: actions/checkout@v3 + - uses: actions/download-artifact@v3 + with: + name: vscode-extension-artifacts + + - name: Display structure of downloaded files + run: ls -R diff --git a/.gitmodules b/.gitmodules index 206278c..bc0dadc 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,18 +7,9 @@ [submodule "hylo"] path = hylo url = https://github.com/koliyo/hylo.git -[submodule "BlueSocket"] - path = BlueSocket - url = https://github.com/Kitura/BlueSocket.git [submodule "swift-unisocket"] path = swift-unisocket url = https://github.com/seznam/swift-unisocket.git -[submodule "Swifty-LLVM"] - path = Swifty-LLVM - url = https://github.com/hylo-lang/Swifty-LLVM.git -[submodule "hylo-lsp-vs-code"] - path = hylo-lsp-vs-code - url = git@github.com:koliyo/hylo-lsp-vs-code.git [submodule "JSONRPC-DataChannel-UniSocket"] path = JSONRPC-DataChannel-UniSocket url = https://github.com/koliyo/JSONRPC-DataChannel-UniSocket.git @@ -31,3 +22,6 @@ [submodule "JSONRPC"] path = JSONRPC url = https://github.com/ChimeHQ/JSONRPC.git +[submodule "hylo-vscode-extension"] + path = hylo-vscode-extension + url = https://github.com/koliyo/hylo-vscode-extension.git diff --git a/Swifty-LLVM b/Swifty-LLVM deleted file mode 160000 index 8e00abf..0000000 --- a/Swifty-LLVM +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 8e00abf2dd4a0e40b403c49816c69a07e829abff diff --git a/build-and-install-vscode-extension.sh b/build-and-install-vscode-extension.sh new file mode 100755 index 0000000..d69fb9f --- /dev/null +++ b/build-and-install-vscode-extension.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -ex + +# . ./setup-env.sh +swift build -c release +BUILD_DIR=$(swift build -c release --show-bin-path) +mkdir -p hylo-vscode-extension/bin/mac/arm64 +cp -fv $BUILD_DIR/hylo-lsp-server hylo-vscode-extension/bin/mac/arm64 +cd hylo-vscode-extension +npm install +npm run vscode:package +VERSION=$(cat package.json | jq -r ".version") +code --install-extension hylo-lang-$VERSION.vsix diff --git a/build-vs-code-extension.sh b/build-vs-code-extension.sh deleted file mode 100755 index 5384ada..0000000 --- a/build-vs-code-extension.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -set -ex - -# . ./setup-env.sh -swift build -c release -BUILD_DIR=$(swift build -c release --show-bin-path) -mkdir -p hylo-lsp-vs-code/bin/mac/arm64 -cp -fv $BUILD_DIR/hylo-lsp-server hylo-lsp-vs-code/bin/mac/arm64 -cd hylo-lsp-vs-code -npm install -npm run vscode:all -code --install-extension hyloc-lsp-0.5.0.vsix diff --git a/hylo-lsp-vs-code b/hylo-lsp-vs-code deleted file mode 160000 index 2166ee9..0000000 --- a/hylo-lsp-vs-code +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 2166ee98231ae2c8209350c83ea6de96951b1e5a diff --git a/hylo-vscode-extension b/hylo-vscode-extension new file mode 160000 index 0000000..2d9d8dc --- /dev/null +++ b/hylo-vscode-extension @@ -0,0 +1 @@ +Subproject commit 2d9d8dc7378462b8a05813e0f251be76ed487aae