mirror of
https://github.com/garethgeorge/backrest.git
synced 2026-05-03 19:40:30 +00:00
109 lines
3.0 KiB
YAML
109 lines
3.0 KiB
YAML
# This workflow will build a golang project
|
|
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
|
|
|
|
name: Test
|
|
|
|
on:
|
|
push:
|
|
branches: ["main"]
|
|
paths-ignore:
|
|
- "docs/**"
|
|
- "*.md"
|
|
pull_request:
|
|
branches: ["main"]
|
|
paths-ignore:
|
|
- "docs/**"
|
|
- "*.md"
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
test-nix:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v4
|
|
with:
|
|
go-version: "1.24"
|
|
|
|
- name: Install gotestsum
|
|
run: go install gotest.tools/gotestsum@latest
|
|
|
|
- name: Create Fake WebUI Sources
|
|
run: |
|
|
mkdir -p webui/dist
|
|
# Create an empty gzip file for testing
|
|
gzip -c /dev/null > webui/dist/index.html.gz
|
|
|
|
- name: Build
|
|
run: go build ./...
|
|
|
|
- name: Test
|
|
run: PATH=$(pwd):$PATH gotestsum ./... -- --race
|
|
|
|
test-win:
|
|
runs-on: windows-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v4
|
|
with:
|
|
go-version: "1.24"
|
|
|
|
- name: Create Fake WebUI Sources
|
|
run: |
|
|
New-Item -Path .\webui\dist-windows\index.html -ItemType File -Force
|
|
|
|
- name: Resolve latest restic version
|
|
shell: powershell
|
|
id: restic-version
|
|
run: |
|
|
$latest = Invoke-RestMethod -Uri "https://api.github.com/repos/restic/restic/releases/latest"
|
|
$tag = $latest.tag_name
|
|
if ($tag.StartsWith("v")) {
|
|
$tag = $tag.Substring(1)
|
|
}
|
|
echo "RESTIC_VERSION=$tag" >> $env:GITHUB_ENV
|
|
|
|
- name: Cache restic
|
|
id: cache-restic
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: restic-bin
|
|
key: restic-windows-${{ env.RESTIC_VERSION }}
|
|
|
|
- name: Download restic
|
|
if: steps.cache-restic.outputs.cache-hit != 'true'
|
|
shell: powershell
|
|
run: |
|
|
$tag = $env:RESTIC_VERSION
|
|
$url = "https://github.com/restic/restic/releases/download/v$tag/restic_${tag}_windows_amd64.zip"
|
|
$output = "restic.zip"
|
|
$dest = "restic-bin"
|
|
|
|
New-Item -ItemType Directory -Force -Path $dest
|
|
|
|
Write-Host "Downloading $url..."
|
|
Invoke-WebRequest -Uri $url -OutFile $output
|
|
Expand-Archive $output -DestinationPath temp_extract -Force
|
|
|
|
$extracted = Get-ChildItem -Recurse -Path temp_extract -Filter "restic*.exe" | Select-Object -First 1
|
|
if ($extracted) {
|
|
Move-Item $extracted.FullName -Destination "$dest\restic.exe" -Force
|
|
} else {
|
|
Write-Error "Could not find restic.exe"
|
|
}
|
|
Remove-Item -Recurse -Force temp_extract
|
|
Remove-Item -Force $output
|
|
|
|
- name: Add restic to PATH
|
|
run: echo "$PWD\restic-bin" >> $env:GITHUB_PATH
|
|
|
|
- name: Build
|
|
run: go build ./...
|
|
|
|
- name: Test
|
|
run: go test ./...
|