From 54a7dd0f06790b3709703bfe2e95e16fbd6cf154 Mon Sep 17 00:00:00 2001 From: Nils Hjelte Date: Sun, 1 Oct 2023 19:30:40 +0200 Subject: [PATCH] Fix CI --- .devcontainer/Dockerfile | 9 ++ .devcontainer/devcontainer.json | 49 ++++++++ .devcontainer/post-create-command.sh | 4 + .github/workflows/build-and-test-template.yml | 110 +++++++++--------- .github/workflows/build-and-test.yml | 1 + .github/workflows/publish-release-version.yml | 14 +-- 6 files changed, 121 insertions(+), 66 deletions(-) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json create mode 100755 .devcontainer/post-create-command.sh diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..b02fc2a --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,9 @@ +ARG SWIFT_VERSION + +FROM swift:${SWIFT_VERSION} + +RUN apt-get update && \ + apt-get install -y \ + libllvm15 llvm-15 llvm-15-dev llvm-15-doc llvm-15-examples llvm-15-runtime + +RUN ln -s /usr/bin/llvm-config-15 /usr/bin/llvm-config diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..76d907c --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,49 @@ +{ + "name": "Swift", + "build": { + "dockerfile": "Dockerfile", + "args": { + "SWIFT_VERSION" : "5.8" + } + }, + "features": { + "ghcr.io/devcontainers/features/common-utils:2": { + "installZsh": "false", + "username": "vscode", + "userUid": "1000", + "userGid": "1000", + "upgradePackages": "false" + }, + "ghcr.io/devcontainers/features/git:1": { + "version": "os-provided", + "ppa": "false" + } + }, + "runArgs": [ + "--cap-add=SYS_PTRACE", + "--security-opt", + "seccomp=unconfined" + ], + // Configure tool-specific properties. + "customizations": { + // Configure properties specific to VS Code. + "vscode": { + // Set *default* container specific settings.json values on container create. + "settings": { + "lldb.library": "/usr/lib/liblldb.so" + }, + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "sswg.swift-lang" + ] + } + }, + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "./.devcontainer/post-create-command.sh", + + // Set `remoteUser` to `root` to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. + "remoteUser": "vscode" +} diff --git a/.devcontainer/post-create-command.sh b/.devcontainer/post-create-command.sh new file mode 100755 index 0000000..e19e6e1 --- /dev/null +++ b/.devcontainer/post-create-command.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +swift --version && swift package resolve +sudo .build/checkouts/Swifty-LLVM/Tools/make-pkgconfig.sh /usr/local/lib/pkgconfig/llvm.pc diff --git a/.github/workflows/build-and-test-template.yml b/.github/workflows/build-and-test-template.yml index 8c28717..3077962 100644 --- a/.github/workflows/build-and-test-template.yml +++ b/.github/workflows/build-and-test-template.yml @@ -28,62 +28,62 @@ on: type: string jobs: - # build-devcontainer-linux: - # name: "Build and test: ${{ matrix.host.os }}/${{ inputs.build-type }}" - # 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 + build-devcontainer-linux: + name: "Build and test: ${{ matrix.host.os }}/${{ inputs.build-type }}" + strategy: + fail-fast: false + matrix: + host: [ + { type: linux, os: ubuntu-latest, + build-options: "--build-tests -Xswiftc -enable-testing", + test-options: "--enable-code-coverage" + } + ] + # configuration: [ "debug", "release" ] - # - uses: actions/cache@v3 - # with: - # path: .build - # key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }} - # restore-keys: | - # ${{ runner.os }}-spm- + runs-on: ${{ matrix.host.os }} + steps: + - uses: actions/checkout@v3 - # - 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 ${{ inputs.build-type }} ${{ matrix.host.build-options }} - # BUILD_DIR=$(swift build -c ${{ inputs.build-type }} --show-bin-path) - # echo "BUILD_DIR=$BUILD_DIR" >> $GITHUB_ENV - # # swift test -c ${{ inputs.build-type }} ${{ 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/${{ inputs.build-type }}/codecov/*.json - - - # - name: Upload Hylo LSP artifacts (${{ inputs.build-type }}) - # uses: actions/upload-artifact@v3 - # with: - # name: hylo-lsp-artifacts-linux - # path: | - # ${{ env.BUILD_DIR }}/hylo-lsp-client - # ${{ env.BUILD_DIR }}/hylo-lsp-server + - 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 ${{ inputs.build-type }} ${{ matrix.host.build-options }} + BUILD_DIR=$(swift build -c ${{ inputs.build-type }} --show-bin-path) + echo "BUILD_DIR=$BUILD_DIR" >> $GITHUB_ENV + # swift test -c ${{ inputs.build-type }} ${{ 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/${{ inputs.build-type }}/codecov/*.json + + + - name: Upload Hylo LSP artifacts (${{ inputs.build-type }}) + uses: actions/upload-artifact@v3 + with: + name: hylo-lsp-artifacts-linux + path: | + ${{ env.BUILD_DIR }}/hylo-lsp-client + ${{ env.BUILD_DIR }}/hylo-lsp-server build-native-macos: name: "Build and test: ${{ matrix.host.os }}/${{ inputs.build-type }}" @@ -95,7 +95,7 @@ jobs: type: macos, os: macos-13, build-options: "--build-tests -Xswiftc -enable-testing", # No coverage support on MacOS - test-options: "-v" + test-options: "" } ] swift: [ diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 387efa4..6f43b37 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -40,6 +40,7 @@ env: jobs: build: + name: Build and test uses: ./.github/workflows/build-and-test-template.yml with: build-type: debug diff --git a/.github/workflows/publish-release-version.yml b/.github/workflows/publish-release-version.yml index 0aedb35..861381c 100644 --- a/.github/workflows/publish-release-version.yml +++ b/.github/workflows/publish-release-version.yml @@ -6,10 +6,12 @@ on: jobs: build: + name: Build and test uses: ./.github/workflows/build-and-test-template.yml with: build-type: release publish-release: + name: Publish release needs: [build] runs-on: ubuntu-latest steps: @@ -19,21 +21,11 @@ jobs: submodules: 'true' - name: Download hylo-lsp-artifacts-mac - id: download-artifact - uses: dawidd6/action-download-artifact@v2 + uses: actions/download-artifact@v3 with: - workflow: build-and-test.yml name: hylo-lsp-artifacts-mac path: hylo-lsp-mac - # - name: Download Hylo LSP artifact-common - # id: download-artifact - # uses: dawidd6/action-download-artifact@v2 - # with: - # workflow: build-and-test.yml - # name: hylo-lsp-artifacts-common - # path: hylo-lsp-artifacts-common - - name: Package Hylo release artifacts run: | set -eo pipefail