Skip to content

Commit

Permalink
Add tests for go1.21 and fix issues building on go1.21 (#137)
Browse files Browse the repository at this point in the history
* Move gin tests to go1.21

* Create archive directories if needed

* Extract go.env from archive tarball

* Remove unneeded code

* Add a changelog entry around installing go.env

* Update fixture package name
  • Loading branch information
joshwlewis committed Aug 15, 2023
1 parent f93f399 commit 8f18c31
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 14 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

- Ensure $GOROOT/go.env is installed.
- Added go1.21.0.

## [0.1.7] - 2023-08-07

- Added go1.19.12, go1.20.7, go1.21rc4.
Expand Down Expand Up @@ -52,4 +54,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[0.1.3]: https://github.com/heroku/buildpacks-go/compare/v0.1.2...v0.1.3
[0.1.2]: https://github.com/heroku/buildpacks-go/compare/v0.1.1...v0.1.2
[0.1.1]: https://github.com/heroku/buildpacks-go/compare/v0.1.0...v0.1.1
[0.1.0]: https://github.com/heroku/buildpacks-go/releases/tag/v0.1.0
[0.1.0]: https://github.com/heroku/buildpacks-go/releases/tag/v0.1.0
2 changes: 1 addition & 1 deletion src/layers/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl Layer for DistLayer {
tgz::fetch_strip_filter_extract_verify(
self.artifact.mirror_tarball_url(),
"go",
["bin", "src", "pkg", "LICENSE"].into_iter(),
["bin", "src", "pkg", "go.env", "LICENSE"].into_iter(),
layer_path,
&self.artifact.sha_checksum,
)
Expand Down
8 changes: 7 additions & 1 deletion src/tgz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use sha2::{
digest::{generic_array::GenericArray, OutputSizeUser},
Digest, Sha256,
};
use std::{io::Read, path::StripPrefixError};
use std::{fs, io::Read, path::StripPrefixError};
use tar::Archive;

#[derive(thiserror::Error, Debug)]
Expand All @@ -23,6 +23,9 @@ pub(crate) enum Error {
#[error("Failed to validate archive checksum; expected {0}, but found {1}")]
Checksum(String, String),

#[error("Error creating archive directory: {0}")]
Directory(std::io::Error),

#[error("Error writing archive entry: {0}")]
Unpack(std::io::Error),

Expand Down Expand Up @@ -65,6 +68,9 @@ pub(crate) fn fetch_strip_filter_extract_verify<'a>(
.iter()
.any(|prefix| path.starts_with(destination.join(prefix)))
{
if let Some(parent) = path.parent() {
fs::create_dir_all(parent).map_err(Error::Directory)?;
}
file.unpack(&path).map_err(Error::Unpack)?;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module example.com/modules_gin_118
module example.com/modules_gin_121

go 1.18
go 1.21

require github.com/gin-gonic/gin v1.8.1

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
func main() {
r := gin.Default()
r.GET("/", func(c *gin.Context) {
c.String(200, "modules_gin_118")
c.String(200, "modules_gin_121")
})
r.Run()
}
16 changes: 8 additions & 8 deletions tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,27 +83,27 @@ fn vendor_gorilla_117_22() {
test_vendor_gorilla_117("heroku/builder:22");
}

fn test_modules_gin_118(builder: &str) {
fn test_modules_gin_121(builder: &str) {
test_go_fixture(
"modules_gin_118",
"modules_gin_121",
builder,
&[
"Detected Go version requirement: =1.18",
"Installing Go 1.18",
"Detected Go version requirement: =1.21",
"Installing Go 1.21",
"downloading github.com/gin-gonic/gin v1.8.1",
],
&[],
);
}
#[test]
#[ignore = "integration test"]
fn modules_gin_118_20() {
test_modules_gin_118("heroku/buildpacks:20");
fn modules_gin_121_20() {
test_modules_gin_121("heroku/buildpacks:20");
}
#[test]
#[ignore = "integration test"]
fn modules_gin_118_22() {
test_modules_gin_118("heroku/builder:22");
fn modules_gin_121_22() {
test_modules_gin_121("heroku/builder:22");
}

fn test_worker_http_118(builder: &str) {
Expand Down

0 comments on commit 8f18c31

Please sign in to comment.