Make github action test different Docker image versions

This commit is contained in:
David Vogel 2025-11-16 14:21:33 +00:00
parent f6b2cda0d5
commit eb8890b7db
2 changed files with 49 additions and 7 deletions

View File

@ -4,8 +4,8 @@ on: [push, pull_request]
jobs:
build:
name: test
test-non-docker:
name: test non-docker
runs-on: ubuntu-latest
strategy:
matrix:
@ -28,4 +28,30 @@ jobs:
uses: actions/checkout@v4
- name: Test package
run: go test -v ./...
run: go test -run ^(?!Docker).*$ -v ./...
test-docker:
name: test docker
runs-on: ubuntu-latest
strategy:
matrix:
go-version: ['1.23.x']
typst-docker-image:
- 'ghcr.io/typst/typst:v0.12.0'
- 'ghcr.io/typst/typst:v0.13.0'
- 'ghcr.io/typst/typst:v0.13.1'
- 'ghcr.io/typst/typst:0.14.0'
steps:
- name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- name: Check out code
uses: actions/checkout@v4
- name: Test package
run: go test -run ^Docker.*$ -v ./...
env:
TYPST_DOCKER_IMAGE: ${{ matrix.typst-docker-image }}

View File

@ -8,6 +8,7 @@ package typst_test
import (
"bytes"
"image"
"os"
"path/filepath"
"strconv"
"testing"
@ -15,8 +16,16 @@ import (
"github.com/Dadido3/go-typst"
)
// Returns the TYPST_DOCKER_IMAGE environment variable.
// If that's not set, it will return an empty string, which makes the tests default to typst.DockerDefaultImage.
func typstDockerImage() string {
return os.Getenv("TYPST_DOCKER_IMAGE")
}
func TestDocker_VersionString(t *testing.T) {
caller := typst.Docker{}
caller := typst.Docker{
Image: typstDockerImage(),
}
_, err := caller.VersionString()
if err != nil {
@ -25,7 +34,9 @@ func TestDocker_VersionString(t *testing.T) {
}
func TestDocker_Fonts(t *testing.T) {
caller := typst.Docker{}
caller := typst.Docker{
Image: typstDockerImage(),
}
result, err := caller.Fonts(nil)
if err != nil {
@ -37,7 +48,9 @@ func TestDocker_Fonts(t *testing.T) {
}
func TestDocker_FontsWithOptions(t *testing.T) {
caller := typst.Docker{}
caller := typst.Docker{
Image: typstDockerImage(),
}
result, err := caller.Fonts(&typst.OptionsFonts{IgnoreSystemFonts: true})
if err != nil {
@ -53,7 +66,9 @@ func TestDocker_Compile(t *testing.T) {
const inches = 1
const ppi = 144
typstCaller := typst.Docker{}
typstCaller := typst.Docker{
Image: typstDockerImage(),
}
r := bytes.NewBufferString(`#set page(width: ` + strconv.FormatInt(inches, 10) + `in, height: ` + strconv.FormatInt(inches, 10) + `in, margin: (x: 1mm, y: 1mm))
= Test
@ -88,6 +103,7 @@ func TestDocker_Compile(t *testing.T) {
// Test basic compile functionality with a given working directory.
func TestDocker_CompileWithWorkingDir(t *testing.T) {
typstCaller := typst.Docker{
Image: typstDockerImage(),
WorkingDirectory: filepath.Join(".", "test-files"),
Volumes: []string{".:/markup"},
}