Skip to content

Commit ae1492a

Browse files
authored
Merge pull request #134 from datalust/ci/github-actions
Initial port of CI to GitHub Actions
2 parents fa90085 + f11fbdc commit ae1492a

8 files changed

Lines changed: 126 additions & 113 deletions

File tree

.github/workflows/ci.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# If this file is renamed, the incrementing run attempt number will be reset.
2+
3+
name: CI
4+
5+
on:
6+
push:
7+
branches: [ "dev", "main" ]
8+
pull_request:
9+
branches: [ "dev", "main" ]
10+
11+
env:
12+
CI_BUILD_NUMBER_BASE: ${{ github.run_number }}
13+
CI_TARGET_BRANCH: ${{ github.head_ref || github.ref_name }}
14+
CI_PUBLISH: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
15+
16+
jobs:
17+
build-windows:
18+
name: Build (Windows)
19+
runs-on: windows-latest
20+
needs: build-linux
21+
22+
permissions:
23+
contents: write
24+
25+
steps:
26+
- uses: actions/checkout@v4
27+
- name: Setup
28+
uses: actions/setup-dotnet@v4
29+
with:
30+
dotnet-version: 10.0.x
31+
- uses: actions/download-artifact@v5
32+
with:
33+
name: sqelf-x86_64-unknown-linux-gnu
34+
path: ./target/x86_64-unknown-linux-gnu/release
35+
- uses: actions/download-artifact@v5
36+
with:
37+
name: sqelf-aarch64-unknown-linux-gnu
38+
path: ./target/aarch64-unknown-linux-gnu/release
39+
- name: Build and Publish
40+
env:
41+
DOTNET_CLI_TELEMETRY_OPTOUT: true
42+
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
43+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44+
shell: pwsh
45+
run: |
46+
./ci/win-x64/build.ps1
47+
48+
build-linux:
49+
name: Build (Linux)
50+
runs-on: ubuntu-22.04
51+
52+
permissions:
53+
contents: write
54+
55+
steps:
56+
- uses: actions/checkout@v4
57+
- name: Setup
58+
uses: actions/setup-dotnet@v4
59+
with:
60+
dotnet-version: 10.0.x
61+
- name: Configure Docker
62+
run: |
63+
docker run --privileged --rm linuxkit/binfmt:bebbae0c1100ebf7bf2ad4dfb9dfd719cf0ef132
64+
sudo service docker restart
65+
- name: Build and Publish
66+
env:
67+
DOTNET_CLI_TELEMETRY_OPTOUT: true
68+
DOCKER_USER: ${{ secrets.DOCKER_USER }}
69+
DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }}
70+
shell: pwsh
71+
run: |
72+
./ci/linux-x64/build.ps1
73+
- uses: actions/upload-artifact@v4
74+
with:
75+
name: sqelf-x86_64-unknown-linux-gnu
76+
path: ./target/x86_64-unknown-linux-gnu/release
77+
- uses: actions/upload-artifact@v4
78+
with:
79+
name: sqelf-aarch64-unknown-linux-gnu
80+
path: ./target/aarch64-unknown-linux-gnu/release

appveyor.yml

Lines changed: 0 additions & 51 deletions
This file was deleted.

baseversion

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
4.0

ci/build-deps.ps1

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
$IsCIBuild = $null -ne $env:APPVEYOR_BUILD_NUMBER
2-
$IsPublishedBuild = $IsCIBuild -and $null -eq $env:APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH
3-
41
function Write-BeginStep($invocation)
52
{
63
Write-Output ""
@@ -13,16 +10,18 @@ function Write-BeginStep($invocation)
1310
Write-Output ""
1411
}
1512

16-
function Get-SemVer($shortver)
13+
function Get-SemVer()
1714
{
18-
# This script originally (c) 2016 Serilog Contributors - license Apache 2.0
19-
$branch = @{ $true = $env:APPVEYOR_REPO_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$env:APPVEYOR_REPO_BRANCH -ne $NULL];
20-
$suffix = @{ $true = ""; $false = ($branch.Substring(0, [math]::Min(10,$branch.Length)) -replace '[\/\+]','-').Trim("-")}[$branch -eq "main"]
15+
$branch = @{ $true = $env:CI_TARGET_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$NULL -ne $env:CI_TARGET_BRANCH];
16+
$revision = @{ $true = "{0:00000}" -f $([convert]::ToInt32($env:CI_BUILD_NUMBER_BASE, 10) + 2300); $false = "local" }[$NULL -ne $env:CI_BUILD_NUMBER_BASE]
17+
$suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)) -replace '([^a-zA-Z0-9\-]*)', '')-$revision"}[$branch -eq "main" -and $revision -ne "local"]
18+
19+
$base = $(Get-Content ./baseversion).Trim()
2120

2221
if ($suffix) {
23-
$shortver + "-" + $suffix
22+
$base + "." + $revision + "-" + $suffix
2423
} else {
25-
$shortver
24+
$base + "." + $revision
2625
}
2726
}
2827

@@ -126,11 +125,8 @@ function Publish-Container($version)
126125
docker tag sqelf-ci:latest-arm64 datalust/sqelf-ci:$version-arm64
127126
if ($LASTEXITCODE) { exit 1 }
128127

129-
if ($IsCIBuild)
130-
{
131-
echo "$env:DOCKER_TOKEN" | docker login -u $env:DOCKER_USER --password-stdin
132-
if ($LASTEXITCODE) { exit 1 }
133-
}
128+
echo "$env:DOCKER_TOKEN" | docker login -u $env:DOCKER_USER --password-stdin
129+
if ($LASTEXITCODE) { exit 1 }
134130

135131
docker push datalust/sqelf-ci:$version-x64
136132
if ($LASTEXITCODE) { exit 1 }
@@ -172,6 +168,7 @@ function Start-SeqEnvironment($protocol) {
172168
docker run --name sqelf-test-seq `
173169
--network sqelf-test `
174170
-e ACCEPT_EULA=Y `
171+
-e SEQ_FIRSTRUN_NOAUTHENTICATION=True `
175172
-itd `
176173
-p 5342:80 `
177174
datalust/seq:latest

ci/linux-x64/build.ps1

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
1-
param (
2-
[string] $shortver = "99.99.99"
3-
)
1+
sudo apt-get update
2+
sudo apt-get install -y libnss3-tools --no-install-recommends
3+
4+
chmod +x ./tool/mkcert-linux-x64
5+
./tool/mkcert-linux-x64 -install
6+
7+
$RequiredRustToolchain=$(cat ./rust-toolchain)
8+
9+
curl https://sh.rustup.rs -sSf | sh -s -- --default-host x86_64-unknown-linux-gnu --default-toolchain $RequiredRustToolchain -y
10+
11+
$env:PATH = "$HOME/.cargo/bin:$env:PATH"
12+
13+
cargo install -f cross
414

5-
$ErrorActionPreference = "Stop"
615
Push-Location "$PSScriptRoot/../../"
716

817
. "./ci/build-deps.ps1"
918

19+
$version = Get-SemVer
20+
1021
function Invoke-SmokeTest($protocol) {
1122
Write-BeginStep $MYINVOCATION
1223

@@ -51,7 +62,7 @@ Build-TestAppContainer
5162
Invoke-SmokeTest("udp")
5263
Invoke-SmokeTest("tcp")
5364

54-
if ($IsPublishedBuild) {
65+
if ($env:CI_PUBLISH) {
5566
Publish-Container (Get-SemVer $shortver)
5667
}
5768
else {

ci/linux-x64/setup.sh

Lines changed: 0 additions & 20 deletions
This file was deleted.

ci/win-x64/build.ps1

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,28 @@
1-
param (
2-
[string] $shortver = "99.99.99"
3-
)
1+
$RequiredRustToolchain = $(cat ./rust-toolchain)
2+
3+
Invoke-WebRequest -OutFile ./rustup-init.exe -Uri https://win.rustup.rs
4+
& ./rustup-init.exe --default-host x86_64-pc-windows-msvc --default-toolchain $RequiredRustToolchain -y
5+
if ($LASTEXITCODE) { exit 1 }
6+
7+
$env:Path = "$HOME\.cargo\bin;$env:Path"
8+
9+
& cargo install -f cross
10+
if ($LASTEXITCODE) { exit 1 }
11+
12+
& rustup toolchain add $RequiredRustToolchain-x86_64-unknown-linux-gnu --force-non-host --profile minimal
13+
& rustup toolchain add $RequiredRustToolchain-aarch64-unknown-linux-gnu --force-non-host --profile minimal
414

5-
$ErrorActionPreference = "Stop"
615
Push-Location "$PSScriptRoot/../../"
716

817
. "./ci/build-deps.ps1"
918

19+
$version = Get-SemVer
20+
1021
Initialize-Filesystem
1122
Invoke-WindowsBuild
1223
Invoke-WindowsTests
13-
Invoke-LinuxBuild
24+
# NOTE: We're relying on GitHub Actions to copy the linux binary across here instead of building locally
25+
# Invoke-LinuxBuild
1426
Invoke-NuGetPack (Get-SemVer $shortver)
1527

16-
Pop-Location
28+
Pop-Location

ci/win-x64/setup.ps1

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)