-
Notifications
You must be signed in to change notification settings - Fork 0
feat: initial v1 release with buildContext schema (SKY-837) #1
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
Closed
eliran-ops
wants to merge
3
commits into
main
from
feat/rename-contextpath-to-buildcontext-default-to-when-absent
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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,72 @@ | ||
| name: test | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
|
|
||
| jobs: | ||
| shell-tests: | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| os: [ubuntu-latest, macos-latest] | ||
| runs-on: ${{ matrix.os }} | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Install yq v4 (linux) | ||
| if: runner.os == 'Linux' | ||
| run: | | ||
| if command -v yq && yq --version | grep -qE 'version v?4\.'; then exit 0; fi | ||
| sudo curl -fsSL --retry 3 --retry-delay 2 \ | ||
| -o /usr/local/bin/yq \ | ||
| https://github.com/mikefarah/yq/releases/download/v4.47.1/yq_linux_amd64 | ||
| sudo chmod +x /usr/local/bin/yq | ||
| yq --version | ||
|
|
||
| - name: Install yq v4 (macos) | ||
| if: runner.os == 'macOS' | ||
| run: brew install yq && yq --version | ||
|
|
||
| - run: bash tests/metadata_test.sh | ||
| - run: bash tests/parse_test.sh | ||
|
|
||
| smoke: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Run action against fixture (buildContext present) | ||
| id: cfg | ||
| uses: ./ | ||
| with: | ||
| working_directory: tests/fixtures | ||
| service_name: smoke-svc | ||
|
|
||
| - name: Verify outputs | ||
| run: | | ||
| set -e | ||
| test "${{ steps.cfg.outputs.config_found }}" = "true" | ||
| test "${{ steps.cfg.outputs.service_found }}" = "true" | ||
| test "${{ steps.cfg.outputs.name }}" = "smoke-svc" | ||
| test "${{ steps.cfg.outputs.path }}" = "services/smoke" | ||
| test "${{ steps.cfg.outputs.deployment_repo }}" = "KoalaOps/deployment" | ||
| test "${{ steps.cfg.outputs.deployment_repo_path }}" = "smoke" | ||
| test "${{ steps.cfg.outputs.build_context }}" = "services/smoke" | ||
| test "${{ steps.cfg.outputs.dockerfile_path }}" = "services/smoke/Dockerfile" | ||
| echo "smoke-svc outputs OK" | ||
|
|
||
| - name: Run action against fixture (buildContext absent -> default '.') | ||
| id: cfg2 | ||
| uses: ./ | ||
| with: | ||
| working_directory: tests/fixtures | ||
| service_name: smoke-default-context | ||
|
|
||
| - name: Verify default-context outputs | ||
| run: | | ||
| set -e | ||
| test "${{ steps.cfg2.outputs.build_context }}" = "." | ||
| test "${{ steps.cfg2.outputs.dockerfile_path }}" = "services/default/Dockerfile" | ||
| echo "default-context outputs OK" |
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,117 @@ | ||
| name: 'Read Skyhook Config' | ||
| description: 'Read service build/deploy config from a Skyhook YAML file (path, dockerfile, build context, deployment repo) by service name' | ||
| author: 'KoalaOps' | ||
|
|
||
| inputs: | ||
| working_directory: | ||
| description: 'Path to the repository root containing .skyhook/skyhook.yaml' | ||
| required: false | ||
| default: '.' | ||
| service_name: | ||
| description: 'Name of the service to look up in the config (must be non-empty)' | ||
| required: true | ||
| config_path: | ||
| description: 'Path to the skyhook config file relative to working_directory' | ||
| required: false | ||
| default: '.skyhook/skyhook.yaml' | ||
|
|
||
| outputs: | ||
| # Service configuration | ||
| name: | ||
| description: 'Service name from config' | ||
| value: ${{ steps.parse.outputs.name }} | ||
| path: | ||
| description: 'Service path relative to repo root' | ||
| value: ${{ steps.parse.outputs.path }} | ||
| deployment_repo: | ||
| description: 'Separate deployment repository (if configured)' | ||
| value: ${{ steps.parse.outputs.deployment_repo }} | ||
| deployment_repo_path: | ||
| description: 'Path within deployment repository' | ||
| value: ${{ steps.parse.outputs.deployment_repo_path }} | ||
|
|
||
| # Build tool configuration | ||
| build_context: | ||
| description: 'Docker build context relative to repo root (defaults to "." when absent in config)' | ||
| value: ${{ steps.parse.outputs.build_context }} | ||
| dockerfile_path: | ||
| description: 'Dockerfile path relative to repo root' | ||
| value: ${{ steps.parse.outputs.dockerfile_path }} | ||
|
|
||
| # Status | ||
| config_found: | ||
| description: 'Whether the config file was found (true/false)' | ||
| value: ${{ steps.parse.outputs.config_found }} | ||
| service_found: | ||
| description: 'Whether the service was found in config (true/false)' | ||
| value: ${{ steps.parse.outputs.service_found }} | ||
|
|
||
| runs: | ||
| using: 'composite' | ||
| steps: | ||
| - name: Install yq (v4) | ||
| shell: bash | ||
| run: | | ||
| set -euo pipefail | ||
| # Accept preinstalled yq only if it is v4.x | ||
| if command -v yq &>/dev/null; then | ||
| if yq --version 2>&1 | grep -qE 'version v?4\.'; then | ||
| echo "Found preinstalled yq: $(yq --version)" | ||
| exit 0 | ||
| fi | ||
| echo "::error::Found yq but not v4.x: $(yq --version 2>&1). Uninstall it or upgrade to v4." | ||
| exit 1 | ||
| fi | ||
|
|
||
| case "$(uname -s)-$(uname -m)" in | ||
| Linux-x86_64) ASSET=yq_linux_amd64 ;; | ||
| Linux-aarch64) ASSET=yq_linux_arm64 ;; | ||
| Darwin-x86_64) ASSET=yq_darwin_amd64 ;; | ||
| Darwin-arm64) ASSET=yq_darwin_arm64 ;; | ||
| *) echo "::error::yq not found and no prebuilt binary for $(uname -s)-$(uname -m). Install yq v4 before using this action."; exit 1 ;; | ||
| esac | ||
|
|
||
| SUDO="" | ||
| [ "$(id -u)" -ne 0 ] && command -v sudo &>/dev/null && SUDO=sudo | ||
| DEST=/usr/local/bin/yq | ||
| URL="https://github.com/mikefarah/yq/releases/download/v4.47.1/${ASSET}" | ||
| echo "Installing yq v4.47.1 from $URL" | ||
|
|
||
| download() { | ||
| if command -v curl &>/dev/null; then | ||
| $SUDO curl -fsSL --retry 3 --retry-delay 2 -o "$DEST" "$URL" | ||
| elif command -v wget &>/dev/null; then | ||
| $SUDO wget -qO "$DEST" "$URL" | ||
| else | ||
| echo "::error::Neither curl nor wget is available; cannot install yq." | ||
| return 2 | ||
| fi | ||
| } | ||
|
|
||
| for attempt in 1 2 3; do | ||
| if download; then | ||
| break | ||
| fi | ||
| rc=$? | ||
| if [ $rc -eq 2 ] || [ $attempt -eq 3 ]; then | ||
| echo "::error::yq download failed (attempt $attempt/3, exit $rc)" | ||
| exit 1 | ||
| fi | ||
| sleep $((attempt * 2)) | ||
| done | ||
|
|
||
| $SUDO chmod +x "$DEST" | ||
| yq --version | ||
|
|
||
| - name: Parse skyhook config | ||
| id: parse | ||
| shell: bash | ||
| env: | ||
| WORKING_DIR: ${{ inputs.working_directory }} | ||
| SERVICE_NAME: ${{ inputs.service_name }} | ||
| CONFIG_PATH: ${{ inputs.config_path }} | ||
| run: bash "$GITHUB_ACTION_PATH/scripts/parse.sh" | ||
|
|
||
| branding: | ||
| icon: 'file-text' | ||
| color: 'blue' | ||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Retry loop never captures download's real exit code
Medium Severity
After
if download; then break; fi,$?is always0per POSIX (noelseclause was executed), sorc=$?on line 95 never captures the actual exit code fromdownload. This makes the$rc -eq 2check on line 96 dead code — when neithercurlnorwgetis available, the loop will pointlessly retry three times (sleeping 6 seconds total) instead of failing immediately. The error message also always reports "exit 0" instead of the real exit code.Reviewed by Cursor Bugbot for commit 3281755. Configure here.