Skip to content

Commit

Permalink
fix(chain): fix issue in release ci and command (#4474)
Browse files Browse the repository at this point in the history
* fix(chain): fix issue in release ci and command

* updates

(cherry picked from commit a0ac845)

# Conflicts:
#	ignite/pkg/archive/tar_gz.go
#	ignite/services/chain/build.go
  • Loading branch information
julienrbrt authored and mergify[bot] committed Jan 17, 2025
1 parent fcf01a4 commit c8f7eb9
Show file tree
Hide file tree
Showing 4 changed files with 157 additions and 0 deletions.
29 changes: 29 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,35 @@

- [#4471](https://github.com/ignite/cli/pull/4471) Bump CometBFT to v0.38.15.
- [#4471](https://github.com/ignite/cli/pull/4471) Bump Ignite & chain minimum Go version to 1.23.
- [#4094](https://github.com/ignite/cli/pull/4094) Scaffolding a multi-index map using `ignite s map foo bar baz --index foobar,foobaz` is no longer supported. Use one index instead of use `collections.IndexedMap`.
- [#4058](https://github.com/ignite/cli/pull/4058) Simplify scaffolded modules by including `ValidateBasic()` logic in message handler.
- [#4058](https://github.com/ignite/cli/pull/4058) Use `address.Codec` instead of `AccAddressFromBech32`.
- [#3993](https://github.com/ignite/cli/pull/3993) Oracle scaffolding was deprecated and has been removed
- [#3962](https://github.com/ignite/cli/pull/3962) Rename all RPC endpoints and autocli commands generated for `map`/`list`/`single` types
- [#3976](https://github.com/ignite/cli/pull/3976) Remove error checks for Cobra command value get calls
- [#4002](https://github.com/ignite/cli/pull/4002) Bump buf build
- [#4008](https://github.com/ignite/cli/pull/4008) Rename `pkg/yaml` to `pkg/xyaml`
- [#4075](https://github.com/ignite/cli/pull/4075) Use `gopkg.in/yaml.v3` instead `gopkg.in/yaml.v2`
- [#4118](https://github.com/ignite/cli/pull/4118) Version scaffolded protos as `v1` to follow SDK structure.
- [#4167](https://github.com/ignite/cli/pull/4167) Scaffold `int64` instead of `int32` when a field type is `int`
- [#4159](https://github.com/ignite/cli/pull/4159) Enable gci linter
- [#4160](https://github.com/ignite/cli/pull/4160) Enable copyloopvar linter
- [#4162](https://github.com/ignite/cli/pull/4162) Enable errcheck linter
- [#4189](https://github.com/ignite/cli/pull/4189) Deprecate `ignite node` for `ignite connect` app
- [#4290](https://github.com/ignite/cli/pull/4290) Remove ignite ics logic from ignite cli (this functionality will be in the `consumer` app)
- [#4295](https://github.com/ignite/cli/pull/4295) Stop scaffolding `pulsar` files
- [#4317](https://github.com/ignite/cli/pull/4317) Remove xchisel dependency
- [#4361](https://github.com/ignite/cli/pull/4361) Remove unused `KeyPrefix` method
- [#4384](https://github.com/ignite/cli/pull/4384) Compare genesis params into chain genesis tests
- [#4463](https://github.com/ignite/cli/pull/4463) Run `chain simulation` with any simulation test case

### Fixes

- [#4000](https://github.com/ignite/cli/pull/4000) Run all dry runners before the wet run in the `xgenny` pkg
- [#4091](https://github.com/ignite/cli/pull/4091) Fix race conditions in the plugin logic
- [#4128](https://github.com/ignite/cli/pull/4128) Check for duplicate proto fields in config
- [#4402](https://github.com/ignite/cli/pull/4402) Fix gentx parser into the cosmosutil package
- [#4474](https://github.com/ignite/cli/pull/4474) Fix issue in `build --release` command

## [`v28.7.0`](https://github.com/ignite/cli/releases/tag/v28.7.0)

Expand Down
122 changes: 122 additions & 0 deletions ignite/pkg/archive/tar_gz.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
package archive

import (
"archive/tar"
"compress/gzip"
"io"
"os"
"path/filepath"

"github.com/ignite/cli/v29/ignite/pkg/errors"

Check failure on line 10 in ignite/pkg/archive/tar_gz.go

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

no required module provides package github.com/ignite/cli/v29/ignite/pkg/errors; to add it:

Check failure on line 10 in ignite/pkg/archive/tar_gz.go

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

no required module provides package github.com/ignite/cli/v29/ignite/pkg/errors; to add it:
)

// CreateArchive creates a tar.gz archive from a list of files.
func CreateArchive(dir string, buf io.Writer) error {
// Create new Writers for gzip and tar
// These writers are chained. Writing to the tar writer will
// write to the gzip writer which in turn will write to
// the "buf" writer
gw := gzip.NewWriter(buf)
defer gw.Close()
tw := tar.NewWriter(gw)
defer tw.Close()

return filepath.WalkDir(dir, func(path string, _ os.DirEntry, _ error) error {
return addToArchive(tw, path)
})
}

func addToArchive(tw *tar.Writer, filename string) error {
// Open the file which will be written into the archive
file, err := os.Open(filename)
if err != nil {
return err
}
defer file.Close()

// Get FileInfo about our file providing file size, mode, etc.
info, err := file.Stat()
if err != nil {
return err
}

// Create a tar Header from the FileInfo data
if info.IsDir() {
hdr, err := tar.FileInfoHeader(info, info.Name())
if err != nil {
return err
}
hdr.Name = filename
if err := tw.WriteHeader(hdr); err != nil {
return err
}

return nil
}

header, err := tar.FileInfoHeader(info, info.Name())
if err != nil {
return err
}

// Use full path as name (FileInfoHeader only takes the basename)
// If we don't do this the directory strucuture would
// not be preserved
// https://golang.org/src/archive/tar/common.go?#L626
header.Name = filename

// Write file header to the tar archive
err = tw.WriteHeader(header)
if err != nil {
return err
}

_, err = io.Copy(tw, file)
if err != nil {
return err
}

return nil
}

// ExtractArchive extracts a tar.gz archive to the specified directory.
func ExtractArchive(outDir string, gzipStream io.Reader) error {
uncompressedStream, err := gzip.NewReader(gzipStream)
if err != nil {
return err
}

tarReader := tar.NewReader(uncompressedStream)

for {
header, err := tarReader.Next()
if err == io.EOF {
break
} else if err != nil {
return err
}

targetPath := filepath.Join(outDir, header.Name) //nolint:gosec // We trust the tar file

switch header.Typeflag {
case tar.TypeDir:
if err := os.MkdirAll(targetPath, 0o755); err != nil {
return err
}
case tar.TypeReg:
outFile, err := os.Create(targetPath)
if err != nil {
return err
}
if _, err := io.Copy(outFile, tarReader); err != nil { //nolint:gosec // We trust the tar file
return err
}
outFile.Close()

default:
return errors.Errorf("unknown type: %s in %s", string(header.Typeflag), header.Name)
}
}

return nil
}
5 changes: 5 additions & 0 deletions ignite/services/chain/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,13 @@ func (c *Chain) BuildRelease(
}
defer tarf.Close()

<<<<<<< HEAD

Check failure on line 198 in ignite/services/chain/build.go

View workflow job for this annotation

GitHub Actions / test network on ubuntu-latest

syntax error: unexpected <<, expected }

Check failure on line 198 in ignite/services/chain/build.go

View workflow job for this annotation

GitHub Actions / test network on macos-latest

syntax error: unexpected <<, expected }

Check failure on line 198 in ignite/services/chain/build.go

View workflow job for this annotation

GitHub Actions / Lint Go code

syntax error: unexpected <<, expected }

Check failure on line 198 in ignite/services/chain/build.go

View workflow job for this annotation

GitHub Actions / Lint Go code

expected statement, found '<<' (typecheck)
if _, err := io.Copy(tarf, tarr); err != nil {
return "", err
=======

Check failure on line 201 in ignite/services/chain/build.go

View workflow job for this annotation

GitHub Actions / test network on ubuntu-latest

syntax error: unexpected ==, expected }

Check failure on line 201 in ignite/services/chain/build.go

View workflow job for this annotation

GitHub Actions / test network on macos-latest

syntax error: unexpected ==, expected }

Check failure on line 201 in ignite/services/chain/build.go

View workflow job for this annotation

GitHub Actions / Lint Go code

syntax error: unexpected ==, expected }

Check failure on line 201 in ignite/services/chain/build.go

View workflow job for this annotation

GitHub Actions / Lint Go code

expected statement, found '==' (typecheck)
if err := archive.CreateArchive(out, tarf); err != nil {
return "", errors.Errorf("error creating release archive: %w", err)
>>>>>>> a0ac8452 (fix(chain): fix issue in release ci and command (#4474))

Check failure on line 204 in ignite/services/chain/build.go

View workflow job for this annotation

GitHub Actions / test network on ubuntu-latest

syntax error: unexpected >>, expected }

Check failure on line 204 in ignite/services/chain/build.go

View workflow job for this annotation

GitHub Actions / test network on ubuntu-latest

invalid character U+0023 '#'

Check failure on line 204 in ignite/services/chain/build.go

View workflow job for this annotation

GitHub Actions / test network on macos-latest

syntax error: unexpected >>, expected }

Check failure on line 204 in ignite/services/chain/build.go

View workflow job for this annotation

GitHub Actions / test network on macos-latest

invalid character U+0023 '#'

Check failure on line 204 in ignite/services/chain/build.go

View workflow job for this annotation

GitHub Actions / Lint Go code

syntax error: unexpected >>, expected }

Check failure on line 204 in ignite/services/chain/build.go

View workflow job for this annotation

GitHub Actions / Lint Go code

invalid character U+0023 '#'

Check failure on line 204 in ignite/services/chain/build.go

View workflow job for this annotation

GitHub Actions / Lint Go code

expected statement, found '>>' (typecheck)
}
tarf.Close()

Check failure on line 206 in ignite/services/chain/build.go

View workflow job for this annotation

GitHub Actions / test network on ubuntu-latest

syntax error: non-declaration statement outside function body

Check failure on line 206 in ignite/services/chain/build.go

View workflow job for this annotation

GitHub Actions / test network on macos-latest

syntax error: non-declaration statement outside function body

Check failure on line 206 in ignite/services/chain/build.go

View workflow job for this annotation

GitHub Actions / Lint Go code

syntax error: non-declaration statement outside function body (typecheck)
}
Expand Down
1 change: 1 addition & 0 deletions ignite/templates/app/files/.github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ jobs:
args: chain build --release --release.prefix ${{ steps.vars.outputs.tarball_prefix }} -t linux:amd64 -t darwin:amd64 -t darwin:arm64 -y
env:
DO_NOT_TRACK: 1
GOFLAGS: "-buildvcs=false"

- name: Delete the "latest" Release
uses: dev-drprasad/[email protected]
Expand Down

0 comments on commit c8f7eb9

Please sign in to comment.