Skip to content

Conversation

tobybellwood
Copy link
Member

@tobybellwood tobybellwood commented Sep 26, 2025

THis PR converts this repo from a fork to a docker build that consumes the upstream repo, but rebuilds it using a more recent version of golang. It also adds a rudimentary set of tests in bats to ensure that the build performs the original tools tasks as required.

mavogel and others added 23 commits October 15, 2021 17:56
chore: update to golang1.17. Closes #38
* chore(ci): add gh actions and templates
* chore: remove travis
* chore(ci): add goreleaser
* fix(makefile): remove old release logic

Closes #28 as well.
* chore(ci): add matrix test
* fix(makefile): add race flag for test
* chore(ci): fix test yaml indentation
* chore(ci): remove windows build env
* chore: bump go version to 1.19
* chore: bump all deps
chore(deps): update golang docker tag to v1.23
chore(deps): update docker/build-push-action action to v6
chore: update github actions
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR converts the repository from a fork to a Docker build system that repackages the upstream envplate tool with an updated Go version (1.25) and adds comprehensive testing.

  • Updates Go version from 1.23 to 1.25 for the build process
  • Adds comprehensive BATS test suite with 9 integration tests covering core functionality
  • Converts from scratch-based to Alpine-based Docker image with proper labels
  • Updates CI/CD workflow to run tests and removes pull request build restrictions

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
envplate.bats New comprehensive test suite covering variable substitution, backup creation, strict mode, and container functionality
README.md Updated documentation explaining the repackaging approach and test suite
Dockerfile Updated Go version, changed base image to Alpine, and added proper OCI labels
.github/workflows/build_and_publish.yml Added BATS test execution and removed pull request build restrictions

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

FROM golang:1.25-alpine AS go-builder

ARG VERSION=v1.0.3
ARG VERSION=v1.0.4-rc.1
Copy link
Preview

Copilot AI Sep 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The VERSION argument is set to v1.0.4-rc.1 but then overridden by pinning to a specific commit hash on line 8. This creates confusion about which version is actually being used. Consider removing the VERSION argument or using it consistently throughout the build.

Copilot uses AI. Check for mistakes.

Comment on lines 150 to 152
size_mb=$(echo "$output" | sed 's/MB//' | cut -d'.' -f1)
[ -n "$size_mb" ]
[ "$size_mb" -lt 20 ]
Copy link
Preview

Copilot AI Sep 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The size parsing logic assumes the output format will always contain 'MB' and have a decimal point, but Docker image sizes can be displayed in different units (KB, GB) or as whole numbers. This will fail for images smaller than 1MB or larger than 999MB. Consider using a more robust parsing approach or docker inspect to get size in bytes.

Suggested change
size_mb=$(echo "$output" | sed 's/MB//' | cut -d'.' -f1)
[ -n "$size_mb" ]
[ "$size_mb" -lt 20 ]
# Parse size and unit, convert to MB
size_value=$(echo "$output" | grep -oE '^[0-9]+(\.[0-9]+)?')
size_unit=$(echo "$output" | grep -oE '[kMGT]?B$')
case "$size_unit" in
kB) size_mb=$(awk "BEGIN {printf \"%.2f\", $size_value/1024}") ;;
MB) size_mb=$size_value ;;
GB) size_mb=$(awk "BEGIN {printf \"%.2f\", $size_value*1024}") ;;
TB) size_mb=$(awk "BEGIN {printf \"%.2f\", $size_value*1024*1024}") ;;
B) size_mb=$(awk "BEGIN {printf \"%.6f\", $size_value/1024/1024}") ;;
*) size_mb=0 ;; # fallback
esac
[ -n "$size_mb" ]
awk "BEGIN {exit ($size_mb < 20 ? 0 : 1)}"

Copilot uses AI. Check for mistakes.

name: Run BATS tests
run: |
IMAGE_REF="${{ steps.meta.outputs.tags }}"
IMAGE_NAME=$(echo "$IMAGE_REF" | head -n1) bats envplate.bats
Copy link
Preview

Copilot AI Sep 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The IMAGE_NAME extraction logic may not work correctly since steps.meta.outputs.tags can contain multiple tags on separate lines. The head -n1 command will get the first line, but the IMAGE_NAME environment variable assignment and bats command are on the same line, which could cause issues. Split this into separate commands for clarity.

Suggested change
IMAGE_NAME=$(echo "$IMAGE_REF" | head -n1) bats envplate.bats
IMAGE_NAME=$(echo "$IMAGE_REF" | head -n1)
bats envplate.bats

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants