-
Notifications
You must be signed in to change notification settings - Fork 5
Expose ProxySQL version as PROXYSQL_VERSION env var #20
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
Open
renecannao
wants to merge
6
commits into
main
Choose a base branch
from
expose-proxysql-version-env
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f4dc27b
Expose ProxySQL version as PROXYSQL_VERSION env var
renecannao a7f22f0
Add GitHub Actions workflows for CI
renecannao 31d7450
Fix CI: use legacy docker build for derived image test, raise hadolin…
renecannao e0130ee
Fix hadolint workflow: run via docker image, skip obsolete dirs
renecannao 43f96ab
Fix hadolint: mount workspace volume so container can access files
renecannao ff7b14f
Address CodeRabbit feedback: robust version resolution, cleanup deriv…
renecannao File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| name: Dockerfile Lint | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
|
|
||
| jobs: | ||
| hadolint: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Run hadolint on active Dockerfiles | ||
| run: | | ||
| find . -name 'Dockerfile*' -not -path './.git/*' -not -path '*/obsolete/*' | while read -r f; do | ||
| echo "Linting: $f" | ||
| docker run --rm -v "${PWD}:/work" -i hadolint/hadolint hadolint --failure-threshold error "/work/$f" | ||
| done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| name: ProxySQL Image Test | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| paths: | ||
| - 'proxysql-images/**' | ||
| pull_request: | ||
| paths: | ||
| - 'proxysql-images/**' | ||
|
|
||
| jobs: | ||
| test: | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| dist: [debian, centos] | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
|
|
||
| - name: Get latest ProxySQL version | ||
| id: version | ||
| run: | | ||
| vers=$(curl -s "https://api.github.com/repos/sysown/proxysql/releases/latest" | jq -r '.tag_name' | sed 's/^v//') | ||
| echo "vers=$vers" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Build and test proxysql-${{ matrix.dist }} | ||
| working-directory: proxysql-images | ||
| run: | | ||
| chmod +x test.sh | ||
| VERS=${{ steps.version.outputs.vers }} DIST=${{ matrix.dist }} ./test.sh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| name: Shellcheck | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
|
|
||
| jobs: | ||
| shellcheck: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Find shell scripts | ||
| id: find | ||
| run: | | ||
| files=$(find . -name '*.sh' -not -path './.git/*' | sort) | ||
| echo "files<<EOF" >> "$GITHUB_OUTPUT" | ||
| echo "$files" >> "$GITHUB_OUTPUT" | ||
| echo "EOF" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Run shellcheck | ||
| if: steps.find.outputs.files != '' | ||
| run: shellcheck ${{ steps.find.outputs.files }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
|
|
||
| VERS="${VERS:-}" | ||
| if [ -z "$VERS" ]; then | ||
| RESPONSE=$(curl -sf --max-time 30 "https://api.github.com/repos/sysown/proxysql/releases/latest") || { | ||
| echo "ERROR: Failed to fetch latest release from GitHub API" >&2 | ||
| exit 1 | ||
| } | ||
| VERS=$(echo "$RESPONSE" | jq -r '.tag_name // empty' | sed 's/^v//') | ||
| if [ -z "$VERS" ]; then | ||
| echo "ERROR: Could not determine latest ProxySQL version from GitHub API response" >&2 | ||
| exit 1 | ||
| fi | ||
| fi | ||
|
|
||
| DIST="${DIST:-debian}" | ||
| IMAGE="proxysql-test:${VERS}-${DIST}" | ||
| DERIVED_IMAGE="proxysql-test-derived:${VERS}-${DIST}" | ||
| FAILED=0 | ||
|
|
||
| cleanup() { | ||
| docker rmi -f "$IMAGE" >/dev/null 2>&1 || true | ||
| docker rmi -f "$DERIVED_IMAGE" >/dev/null 2>&1 || true | ||
| } | ||
| trap cleanup EXIT | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| echo "=== Testing proxysql-${DIST} with VERS=${VERS} ===" | ||
|
|
||
| docker buildx build --build-arg VERS="$VERS" -t "$IMAGE" --load -q "${SCRIPT_DIR}/proxysql-${DIST}" | ||
|
|
||
| echo "--- Test 1: PROXYSQL_VERSION env var is set ---" | ||
| ENV_VERSION=$(docker run --rm "$IMAGE" printenv PROXYSQL_VERSION) | ||
| if [ "$ENV_VERSION" = "$VERS" ]; then | ||
| echo "PASS: PROXYSQL_VERSION=${ENV_VERSION}" | ||
| else | ||
| echo "FAIL: expected PROXYSQL_VERSION=${VERS}, got '${ENV_VERSION}'" | ||
| FAILED=1 | ||
| fi | ||
|
|
||
| echo "--- Test 2: PROXYSQL_VERSION matches installed proxysql version ---" | ||
| INSTALLED_VERSION=$(docker run --rm "$IMAGE" proxysql --version 2>/dev/null | grep -oP 'ProxySQL version \K[0-9]+\.[0-9]+\.[0-9]+' || true) | ||
| if [ -z "$INSTALLED_VERSION" ]; then | ||
| INSTALLED_VERSION=$(docker run --rm "$IMAGE" proxysql --version 2>&1 | sed -n 's/.*ProxySQL version \([0-9.]*\).*/\1/p') | ||
| fi | ||
| if [ "$INSTALLED_VERSION" = "$VERS" ]; then | ||
| echo "PASS: installed version matches (${INSTALLED_VERSION})" | ||
| else | ||
| echo "FAIL: installed version '${INSTALLED_VERSION}' != expected '${VERS}'" | ||
| FAILED=1 | ||
| fi | ||
|
|
||
| echo "--- Test 3: ENV is inherited by derived images ---" | ||
| DERIVED_IMAGE="proxysql-test-derived:${VERS}-${DIST}" | ||
| TMPDIR_DERIVED=$(mktemp -d) | ||
| echo "FROM ${IMAGE}" > "${TMPDIR_DERIVED}/Dockerfile" | ||
| docker build -t "$DERIVED_IMAGE" "$TMPDIR_DERIVED" -q | ||
| rm -rf "$TMPDIR_DERIVED" | ||
| DERIVED_VERSION=$(docker run --rm "$DERIVED_IMAGE" printenv PROXYSQL_VERSION) | ||
| if [ "$DERIVED_VERSION" = "$VERS" ]; then | ||
| echo "PASS: derived image inherits PROXYSQL_VERSION=${DERIVED_VERSION}" | ||
| else | ||
| echo "FAIL: derived image PROXYSQL_VERSION='${DERIVED_VERSION}', expected '${VERS}'" | ||
| FAILED=1 | ||
| fi | ||
|
|
||
| echo "" | ||
| if [ "$FAILED" -eq 0 ]; then | ||
| echo "=== All tests PASSED ===" | ||
| else | ||
| echo "=== Some tests FAILED ===" | ||
| exit 1 | ||
| fi | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.