Skip to content

Commit

Permalink
ci: add Windows builds using MinGW toolchain
Browse files Browse the repository at this point in the history
This commit implements Windows testing and builds using MinGW toolchain.
Some details about the implementation:

- DLLs are built within CI from Microsoft's vcpkg repository as it appears
  to be the most reliable source for pinned versions out there.
- MinGW toolchain comes from https://github.com/niXman/mingw-builds-binaries
  as they provide a toolchain with little to no extras, reducing variables
  and binary surface in our builds. This toolchain targets UCRT runtime, which
  is bundled with Windows 10 and above.
  • Loading branch information
alaviss committed Jan 20, 2024
1 parent 4800d23 commit 0a2e69e
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 2 deletions.
33 changes: 33 additions & 0 deletions .github/actions/setup-mingw/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Setup MinGW environment
description: Download and setup MinGW environment for Windows
inputs:
mingw-version:
description: The release tag from niXman/mingw-builds-binaries to use
required: false
default: "13.2.0-rt_v11-rev1"

runs:
using: "composite"
steps:
- if: runner.os != 'Windows'
name: Error when used on non-Windows runners
run: |
echo "::error::This action does not support $RUNNER_OS"
exit 1
shell: bash

- name: Download from niXman/mingw-builds-binaries
id: download
uses: robinraju/[email protected]
with:
repository: niXman/mingw-builds-binaries
tag: ${{ inputs.mingw-version }}
fileName: x86_64-*-win32-*-ucrt*.7z

- name: Extract MinGW and add to PATH
run: |
7z x "$MINGW_ARCHIVE"
echo "$RUNNER_TEMP/mingw32/bin" >> "$GITHUB_PATH"
shell: bash
env:
MINGW_ARCHIVE: ${{ fromJson(steps.download.outputs.downloaded_files)[0] }}
65 changes: 63 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ jobs:
{
"name": "macOS",
"runner": "macos-11"
},
{
"name": "Windows",
"runner": "windows-2019"
}
]
EOF
Expand Down Expand Up @@ -123,6 +127,28 @@ jobs:
- name: Enable annotations
run: echo "::add-matcher::.github/nim-problem-matcher.json"

- name: Install MinGW (Windows)
if: runner.os == 'Windows'
uses: ./.github/actions/setup-mingw

- name: Install dependencies (Windows)
if: runner.os == 'Windows'
uses: johnwason/vcpkg-action@v6
with:
pkgs: >-
pcre
sqlite3
triplet: x64-mingw-dynamic-release
extra-args: --host-triplet=x64-mingw-dynamic-release
revision: 2024.01.12
github-binarycache: true

- name: Install DLLs (Windows)
if: runner.os == 'Windows'
run: |
cp vcpkg/install/bin/libsqlite3.dll bin/sqlite3.dll
cp vcpkg/install/bin/libpcre.dll bin/pcre64.dll
- name: Build release binaries
run: ./koch.py all-strict

Expand Down Expand Up @@ -180,6 +206,10 @@ jobs:
run: |
brew update
- name: Install MinGW (Windows)
if: runner.os == 'Windows'
uses: ./.github/actions/setup-mingw

- name: Run tester
run: ./koch.py test --batch:'${{ matrix.batch }}_${{ matrix.total_batch }}' --tryFailing all

Expand Down Expand Up @@ -207,6 +237,10 @@ jobs:

- uses: ./.github/actions/download-compiler

- name: Install MinGW (Windows)
if: runner.os == 'Windows'
uses: ./.github/actions/setup-mingw

- name: Enable annotations
run: echo "::add-matcher::.github/nim-problem-matcher.json"

Expand All @@ -227,6 +261,10 @@ jobs:

- uses: ./.github/actions/download-compiler

- name: Install MinGW (Windows)
if: runner.os == 'Windows'
uses: ./.github/actions/setup-mingw

- name: Enable annotations
run: echo "::add-matcher::.github/nim-problem-matcher.json"

Expand Down Expand Up @@ -269,6 +307,17 @@ jobs:
runs-on: ${{ matrix.target.runner }}

steps:
- name: Get actions
uses: actions/checkout@v4
with:
fetch-depth: 0
path: git-src
sparse-checkout: .github/actions

- name: Install MinGW (Windows)
if: runner.os == 'Windows'
uses: ./git-src/.github/actions/setup-mingw

- name: Download source archive
uses: actions/download-artifact@v4
with:
Expand Down Expand Up @@ -298,7 +347,11 @@ jobs:
- id: package
name: Create release package
run: |
./koch.py unixrelease
if [[ "$RUNNER_OS" == Windows ]]; then
./koch.py winrelease
else
./koch.py unixrelease
fi
archive=build/archive/$(jq -r .name build/archive/archive.json)
# Rename the archive manifest to avoid collision with other artifacts
Expand Down Expand Up @@ -340,6 +393,10 @@ jobs:

- uses: ./.github/actions/download-compiler

- name: Install MinGW (Windows)
if: runner.os == 'Windows'
uses: ./.github/actions/setup-mingw

- name: Enable annotations
run: echo "::add-matcher::.github/nim-problem-matcher.json"

Expand All @@ -357,7 +414,11 @@ jobs:
- id: package
name: Create release package
run: |
./koch.py unixrelease
if [[ "$RUNNER_OS" == Windows ]]; then
./koch.py winrelease
else
./koch.py unixrelease
fi
archive=build/archive/$(jq -r .name build/archive/archive.json)
# Rename the archive manifest to avoid collision with other artifacts
Expand Down

0 comments on commit 0a2e69e

Please sign in to comment.