Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update go and gdal versions on CI #126

Merged
merged 3 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
matrix:
os: [ 'ubuntu-20.04', 'ubuntu-22.04' ]
go: [ '1.21' ]
go: [ '1.22' ]
name: Go ${{ matrix.go }} + GDAL on ${{ matrix.os }} test
steps:
- name: APT
Expand All @@ -31,7 +31,7 @@ jobs:
runs-on: ubuntu-22.04
strategy:
matrix:
gdal: [ 'release/3.5', 'release/3.6', 'release/3.7', 'release/3.8', 'master' ]
gdal: [ 'release/3.6', 'release/3.7', 'release/3.8', 'release/3.9', 'master' ]
steps:
- name: optgdal
run: sudo mkdir /optgdal && sudo chown -R $USER /optgdal
Expand All @@ -51,8 +51,8 @@ jobs:
runs-on: ubuntu-22.04
strategy:
matrix:
go: [ '1.20', '1.21' ]
gdal: [ 'release/3.5', 'release/3.6', 'release/3.7', 'release/3.8', 'master' ]
go: [ '1.21', '1.22' ]
gdal: [ 'release/3.6', 'release/3.7', 'release/3.8', 'release/3.9', 'master' ]
name: Go ${{ matrix.go }} + GDAL ${{ matrix.gdal }} test
steps:
- name: APT
Expand Down Expand Up @@ -90,12 +90,12 @@ jobs:
env:
PKG_CONFIG_PATH: /optgdal/lib/pkgconfig/
- name: Send coverage
if: ${{ matrix.go == '1.21' && matrix.gdal == 'master' }}
if: ${{ matrix.go == '1.22' && matrix.gdal == 'master' }}
uses: shogo82148/actions-goveralls@v1
with:
path-to-profile: profile.cov
- name: golangci-lint
if: ${{ matrix.go == '1.21' && matrix.gdal == 'master' }}
if: ${{ matrix.go == '1.22' && matrix.gdal == 'master' }}
uses: reviewdog/action-golangci-lint@v1
env:
PKG_CONFIG_PATH: /optgdal/lib/pkgconfig/
Expand Down
23 changes: 14 additions & 9 deletions godal.go
Original file line number Diff line number Diff line change
Expand Up @@ -1582,13 +1582,22 @@ func (lv LibVersion) Revision() int {

// AssertMinVersion will panic if the runtime version is not at least major.minor.revision
func AssertMinVersion(major, minor, revision int) {
if !CheckMinVersion(major, minor, revision) {
runtimeVersion := Version()
panic(fmt.Errorf("runtime version %d.%d.%d < %d.%d.%d",
runtimeVersion.Major(), runtimeVersion.Minor(), runtimeVersion.Revision(), major, minor, revision))
}
}

// CheckMinVersion will return true if the runtime version is at least major.minor.revision
func CheckMinVersion(major, minor, revision int) bool {
runtimeVersion := Version()
if runtimeVersion.Major() < major ||
(runtimeVersion.Major() == major && runtimeVersion.Minor() < minor) ||
(runtimeVersion.Major() == major && runtimeVersion.Minor() == minor && runtimeVersion.Revision() < revision) {
panic(fmt.Errorf("runtime version %d.%d.%d < %d.%d.%d",
runtimeVersion.Major(), runtimeVersion.Minor(), runtimeVersion.Revision(), major, minor, revision))
return false
}
return true
}

func init() {
Expand Down Expand Up @@ -3508,11 +3517,7 @@ func (g *Geometry) GML(opts ...GMLExportOption) (string, error) {
for _, o := range opts {
o.setGMLExportOpt(gmlo)
}
switches := make([]string, len(gmlo.creation))
for i, copt := range gmlo.creation {
switches[i] = copt
}
cswitches := sliceToCStringArray(switches)
cswitches := sliceToCStringArray(gmlo.creation)
defer cswitches.free()
cgc := createCGOContext(nil, gmlo.errorHandler)
cgml := C.godalExportGeometryGML(cgc.cPointer(), g.handle, cswitches.cPointer())
Expand Down Expand Up @@ -3965,8 +3970,8 @@ func (ds *Dataset) Nearblack(dstDS string, switches []string, opts ...NearblackO

cgc := createCGOContext(nil, nearBlackOpts.errorHandler)

ret, err := C.godalNearblack(cgc.cPointer(), (*C.char)(dest), nil, ds.handle(), cswitches.cPointer())
if err = cgc.close(); err != nil {
ret := C.godalNearblack(cgc.cPointer(), (*C.char)(dest), nil, ds.handle(), cswitches.cPointer())
if err := cgc.close(); err != nil {
return nil, err
}

Expand Down
34 changes: 19 additions & 15 deletions godal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,7 @@ func TestRegisterDrivers(t *testing.T) {
_, ok = VectorDriver("Mapinfo File")
assert.True(t, ok)

runtimeVersion := Version()
supported := runtimeVersion.Major() > 3 ||
(runtimeVersion.Major() == 3 && runtimeVersion.Minor() >= 8)
supported := CheckMinVersion(3, 8, 0)

ehc := eh()
err = RegisterPlugin("foobarsljgsa", ErrLogger(ehc.ErrorHandler))
Expand Down Expand Up @@ -343,7 +341,7 @@ func TestConfigOptions(t *testing.T) {
//Create. withtout the configoption create() will fail
ds, err := Create(GTiff, tiffile, 1, Byte, 1024, 1024, CreationOption("INVALID_OPTION=TRUE"), ConfigOption("GDAL_VALIDATE_CREATION_OPTIONS=FALSE"))
assert.NoError(t, err)
_, _ = ds.CreateMaskBand(0x02) //tmpdir/testfile.msk
_, _ = ds.CreateMaskBand(0x02) //For gdal <3.9, this will create tmpdir/testfile.msk
_ = ds.Close()

//Open
Expand Down Expand Up @@ -395,7 +393,11 @@ func TestConfigOptions(t *testing.T) {
ds, _ = Open(tiffile, ConfigOption("GDAL_DISABLE_READDIR_ON_OPEN=EMPTY_DIR"))
_, err = ds.GeoTransform()
assert.Error(t, err)
assert.NotEqual(t, 0x02, ds.Bands()[0].MaskFlags())
if CheckMinVersion(3, 9, 0) {
assert.Equal(t, 0x02, ds.Bands()[0].MaskFlags()) //gdal 3.9+ will not create a separate mask file by default
} else {
assert.NotEqual(t, 0x02, ds.Bands()[0].MaskFlags())
}
}

func TestHistogram(t *testing.T) {
Expand Down Expand Up @@ -628,6 +630,8 @@ func TestStructure(t *testing.T) {

func TestVersion(t *testing.T) {
AssertMinVersion(3, 0, 0)
assert.False(t, CheckMinVersion(99, 99, 99))
assert.True(t, CheckMinVersion(3, 0, 0))
assert.Panics(t, func() { AssertMinVersion(99, 99, 99) })
}

Expand Down Expand Up @@ -1303,9 +1307,12 @@ func TestOpenUpdate(t *testing.T) {
}
uds, _ = Open(tt)
flags := uds.Bands()[0].MaskFlags()
if flags != 0x8 {
t.Errorf("mask was used: %d", flags)
if CheckMinVersion(3, 9, 0) {
assert.Equal(t, 0x2, flags, "mask not set")
} else {
assert.Equal(t, 0x8, flags, "mask not being set from nodata values")
}

_ = uds.Close()
uds, _ = Open(tt, SiblingFiles(filepath.Base(tt+".msk")))
flags = uds.Bands()[0].MaskFlags()
Expand Down Expand Up @@ -1641,7 +1648,7 @@ func TestProjMisc(t *testing.T) {
attr, ok := sr.AttrValue("GEOGCS", 0)
assert.True(t, ok)
assert.Equal(t, "WGS 84", attr)
attr, ok = sr.AttrValue("GEOGCS", 9999)
_, ok = sr.AttrValue("GEOGCS", 9999)
assert.False(t, ok)

err = sr.AutoIdentifyEPSG()
Expand Down Expand Up @@ -2703,8 +2710,7 @@ func TestLayerModifyFeatures(t *testing.T) {
l = dsm.Layers()[0]

err = l.SetGeometryColumnName("no_error_after_3.6")
runtimeVersion := Version()
if runtimeVersion.Major() <= 3 && runtimeVersion.Minor() < 6 {
if !CheckMinVersion(3, 6, 0) {
assert.Error(t, err)
} else {
assert.NoError(t, err)
Expand Down Expand Up @@ -3083,8 +3089,7 @@ func TestFeatureAttributes(t *testing.T) {

ehc = eh()
err = nf.SetGeometryColumnName("no_error_before_3_9", ErrLogger(ehc.ErrorHandler))
runtimeVersion := Version()
if runtimeVersion.Major() <= 3 && runtimeVersion.Minor() < 9 {
if !CheckMinVersion(3, 9, 0) {
assert.NoError(t, err)
} else {
assert.Error(t, err)
Expand Down Expand Up @@ -3941,16 +3946,15 @@ func TestStatistics(t *testing.T) {
assert.Equal(t, 10., stats.Mean)
assert.Equal(t, 0.29, stats.Std)
assert.Equal(t, false, stats.Approximate)
runtimeVersion := Version()
err = ds.ClearStatistics()
if runtimeVersion.Major() <= 3 && runtimeVersion.Minor() < 2 {
if !CheckMinVersion(3, 2, 0) {
assert.Error(t, err)
} else {
assert.NoError(t, err)
}
ehc = eh()
err = ds.ClearStatistics(ErrLogger(ehc.ErrorHandler))
if runtimeVersion.Major() <= 3 && runtimeVersion.Minor() < 2 {
if !CheckMinVersion(3, 2, 0) {
assert.Error(t, err)
} else {
assert.NoError(t, err)
Expand Down
Loading