mirror of
https://github.com/Dadido3/go-typst.git
synced 2025-11-20 11:49:36 +00:00
Make github action test different Docker image versions
This commit is contained in:
parent
f6b2cda0d5
commit
eb8890b7db
32
.github/workflows/test.yml
vendored
32
.github/workflows/test.yml
vendored
@ -4,8 +4,8 @@ on: [push, pull_request]
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|
||||||
build:
|
test-non-docker:
|
||||||
name: test
|
name: test non-docker
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
@ -28,4 +28,30 @@ jobs:
|
|||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Test package
|
- 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 }}
|
||||||
|
|||||||
@ -8,6 +8,7 @@ package typst_test
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"image"
|
"image"
|
||||||
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
"testing"
|
"testing"
|
||||||
@ -15,8 +16,16 @@ import (
|
|||||||
"github.com/Dadido3/go-typst"
|
"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) {
|
func TestDocker_VersionString(t *testing.T) {
|
||||||
caller := typst.Docker{}
|
caller := typst.Docker{
|
||||||
|
Image: typstDockerImage(),
|
||||||
|
}
|
||||||
|
|
||||||
_, err := caller.VersionString()
|
_, err := caller.VersionString()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -25,7 +34,9 @@ func TestDocker_VersionString(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestDocker_Fonts(t *testing.T) {
|
func TestDocker_Fonts(t *testing.T) {
|
||||||
caller := typst.Docker{}
|
caller := typst.Docker{
|
||||||
|
Image: typstDockerImage(),
|
||||||
|
}
|
||||||
|
|
||||||
result, err := caller.Fonts(nil)
|
result, err := caller.Fonts(nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -37,7 +48,9 @@ func TestDocker_Fonts(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestDocker_FontsWithOptions(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})
|
result, err := caller.Fonts(&typst.OptionsFonts{IgnoreSystemFonts: true})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -53,7 +66,9 @@ func TestDocker_Compile(t *testing.T) {
|
|||||||
const inches = 1
|
const inches = 1
|
||||||
const ppi = 144
|
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))
|
r := bytes.NewBufferString(`#set page(width: ` + strconv.FormatInt(inches, 10) + `in, height: ` + strconv.FormatInt(inches, 10) + `in, margin: (x: 1mm, y: 1mm))
|
||||||
= Test
|
= Test
|
||||||
@ -88,6 +103,7 @@ func TestDocker_Compile(t *testing.T) {
|
|||||||
// Test basic compile functionality with a given working directory.
|
// Test basic compile functionality with a given working directory.
|
||||||
func TestDocker_CompileWithWorkingDir(t *testing.T) {
|
func TestDocker_CompileWithWorkingDir(t *testing.T) {
|
||||||
typstCaller := typst.Docker{
|
typstCaller := typst.Docker{
|
||||||
|
Image: typstDockerImage(),
|
||||||
WorkingDirectory: filepath.Join(".", "test-files"),
|
WorkingDirectory: filepath.Join(".", "test-files"),
|
||||||
Volumes: []string{".:/markup"},
|
Volumes: []string{".:/markup"},
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user