mirror of
https://github.com/garethgeorge/backrest.git
synced 2026-07-16 23:18:01 +00:00
44966241cb
Release Please / release-please (push) Has been cancelled
Release Preview / call-reusable-release (push) Has been cancelled
Test / test-nix (push) Has been cancelled
Test / test-webui (push) Has been cancelled
Test / test-e2e-web (push) Has been cancelled
Test / test-win (push) Has been cancelled
224 lines
6.3 KiB
YAML
224 lines
6.3 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:
|
|
paths-ignore:
|
|
- "docs/**"
|
|
- "*.md"
|
|
pull_request:
|
|
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-webui:
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
TZ: UTC
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Setup pnpm
|
|
uses: pnpm/action-setup@v4
|
|
with:
|
|
version: 9
|
|
|
|
- name: Setup Node
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: "20"
|
|
cache: pnpm
|
|
cache-dependency-path: webui/pnpm-lock.yaml
|
|
|
|
- name: Install dependencies
|
|
run: cd webui && pnpm install --frozen-lockfile
|
|
|
|
# Runs compile-i18n (paraglide) first, then vitest.
|
|
- name: Test
|
|
run: cd webui && pnpm test
|
|
|
|
- name: Typecheck
|
|
run: cd webui && pnpm run check
|
|
|
|
test-e2e-web:
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
# Not RCLONE_*: rclone reads RCLONE_VERSION as its --version flag.
|
|
E2E_RCLONE_VERSION: v1.69.1
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v4
|
|
with:
|
|
go-version: "1.24"
|
|
|
|
- name: Setup pnpm
|
|
uses: pnpm/action-setup@v4
|
|
with:
|
|
version: 9
|
|
|
|
- name: Setup Node
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: "20"
|
|
cache: pnpm
|
|
cache-dependency-path: webui/pnpm-lock.yaml
|
|
|
|
- name: Install dependencies
|
|
run: cd webui && pnpm install --frozen-lockfile
|
|
|
|
- name: Build WebUI
|
|
run: cd webui && pnpm run build
|
|
|
|
- name: Build backrest binary (embeds the real WebUI)
|
|
run: |
|
|
mkdir -p webui/e2e/.cache
|
|
go build -o webui/e2e/.cache/backrest ./cmd/backrest
|
|
|
|
# Keyed on the file that pins RequiredResticVersion; global-setup
|
|
# provisions restic into this directory on a cache miss.
|
|
- name: Cache restic
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: webui/e2e/.cache/restic-data
|
|
key: restic-e2e-${{ hashFiles('internal/resticinstaller/resticinstaller.go') }}
|
|
|
|
- name: Cache playwright browsers
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ~/.cache/ms-playwright
|
|
key: playwright-${{ hashFiles('webui/pnpm-lock.yaml') }}
|
|
|
|
- name: Install playwright chromium
|
|
run: cd webui && pnpm exec playwright install --with-deps chromium
|
|
|
|
# restic's rclone backend spawns the `rclone` binary; the rclone-repo
|
|
# e2e spec skips itself if rclone is absent, so provision it for coverage.
|
|
- name: Cache rclone
|
|
id: cache-rclone
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: webui/e2e/.cache/rclone-bin
|
|
key: rclone-${{ env.E2E_RCLONE_VERSION }}
|
|
|
|
- name: Install rclone
|
|
run: |
|
|
dest="$PWD/webui/e2e/.cache/rclone-bin"
|
|
if [ ! -x "$dest/rclone" ]; then
|
|
mkdir -p "$dest"
|
|
zip="rclone-${E2E_RCLONE_VERSION}-linux-amd64"
|
|
curl -fsSL "https://downloads.rclone.org/${E2E_RCLONE_VERSION}/${zip}.zip" -o /tmp/rclone.zip
|
|
unzip -j -o /tmp/rclone.zip "${zip}/rclone" -d "$dest"
|
|
chmod +x "$dest/rclone"
|
|
fi
|
|
echo "$dest" >> "$GITHUB_PATH"
|
|
|
|
- name: Run e2e tests
|
|
run: |
|
|
cd webui
|
|
E2E_SKIP_WEBUI_BUILD=1 E2E_BACKREST_BIN=$PWD/e2e/.cache/backrest pnpm run e2e
|
|
|
|
- name: Upload playwright report
|
|
uses: actions/upload-artifact@v4
|
|
if: failure()
|
|
with:
|
|
name: playwright-report
|
|
path: |
|
|
webui/playwright-report/
|
|
webui/test-results/
|
|
|
|
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 ./...
|