Modernize CI configuration #54
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Test libsodiumd on all three platforms | |
name: Test | |
on: [pull_request, push] | |
jobs: | |
main: | |
name: Run | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ ubuntu-latest, macOS-latest, windows-latest ] | |
dc: [ dmd-master, ldc-master, dmd-latest, ldc-latest ] | |
exclude: | |
# https://github.com/dlang/dub/issues/1914 | |
# https://github.com/dlang/dub/issues/1915 | |
- { os: windows-latest, dc: dmd-master } | |
- { os: windows-latest, dc: dmd-latest } | |
- { os: macOS-latest, dc: dmd-master } | |
- { os: macOS-latest, dc: dmd-latest } | |
runs-on: ${{ matrix.os }} | |
timeout-minutes: 30 | |
steps: | |
# Checkout this repository | |
- uses: actions/checkout@v4 | |
# Install the D compiler | |
- name: Prepare compiler | |
uses: dlang-community/setup-dlang@v1 | |
with: | |
compiler: ${{ matrix.dc }} | |
# Install os-specific packages. | |
# We only need pkg-config and libsodium, which *might* already be installed. | |
# See https://github.com/actions/runner-images for included software / libraries | |
- name: '[Linux] Install dependencies' | |
if: runner.os == 'Linux' | |
run: | | |
sudo add-apt-repository ppa:ubuntu-toolchain-r/test | |
sudo apt-get update | |
sudo apt-get install libsodium-dev | |
- name: '[Windows] Load libsodium from cache' | |
id: cache-libsodium | |
if: runner.os == 'Windows' | |
uses: actions/cache@v4 | |
with: | |
path: ${{ github.workspace }}\lib\libsodium\x64\Release\v142\static\ | |
key: libsodium-1.0.18 | |
- name: '[Windows] Install dependencies' | |
if: runner.os == 'Windows' && steps.cache-libsodium.outputs.cache-hit != 'true' | |
run: | | |
# TODO: Read the version from the base ref | |
$url = "https://github.com/jedisct1/libsodium/releases/download/1.0.18-RELEASE/libsodium-1.0.18-msvc.zip" | |
$sha256hash = "C1D48D85C9361E350931FFE5067559CD7405A697C655D26955FB568D1084A5F4" | |
Write-Host ('Downloading {0} ...' -f $url) | |
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 | |
# See https://github.com/PowerShell/PowerShell/issues/2138 | |
$ProgressPreference = 'SilentlyContinue' | |
New-Item -ItemType directory -Path ${{ github.workspace }}\lib\ | |
Invoke-WebRequest -Uri $url -OutFile '${{ github.workspace }}\lib\libsodium.zip' | |
if ((Get-FileHash '${{ github.workspace }}\lib\libsodium.zip' -Algorithm "SHA256").Hash -ne $sha256hash) { | |
exit 1 | |
} | |
Expand-Archive '${{ github.workspace }}\lib\libsodium.zip' -DestinationPath '${{ github.workspace }}\lib\' | |
# Build and run the tests | |
- name: '[POSIX] Build & test' | |
if: runner.os != 'Windows' | |
run: dub test --compiler=${{ env.DC }} | |
- name: '[Windows] Build & test' | |
if: runner.os == 'Windows' | |
shell: cmd | |
env: | |
LIB: ${{ github.workspace }}\lib\libsodium\x64\Release\v142\static\;$LIB | |
run: | | |
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat" | |
dub test --compiler=${{ env.DC }} | |
if %errorlevel% neq 0 exit /b %errorlevel% | |
- name: 'Upload code coverage' | |
uses: codecov/codecov-action@v4 | |
with: | |
flags: unittests |