-
Notifications
You must be signed in to change notification settings - Fork 0
feat(gitlab-ci-local): add NOTES.md, clean up install script, and add generate-docs recipe #14
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
Changes from all commits
ea47b50
f6e5c7c
e1cdd82
bd54ea6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| ## About | ||
|
|
||
| Tired of pushing to test your `.gitlab-ci.yml`? `gitlab-ci-local` lets you run GitLab CI/CD pipelines locally as a shell executor or docker executor. | ||
|
|
||
| For more information, see: https://github.com/firecow/gitlab-ci-local | ||
|
|
||
| ## How It Works | ||
|
|
||
| 1. **Downloads the binary** from [firecow/gitlab-ci-local](https://github.com/firecow/gitlab-ci-local) GitHub releases | ||
| 2. **Installs to** `/usr/local/bin/gitlab-ci-local` | ||
| 3. **Supports** both `amd64` and `arm64` architectures | ||
|
|
||
| ## Usage | ||
|
|
||
| Run a pipeline locally from a project with a `.gitlab-ci.yml`: | ||
|
|
||
| ```bash | ||
| gitlab-ci-local | ||
| ``` | ||
|
|
||
| Run a specific job: | ||
|
|
||
| ```bash | ||
| gitlab-ci-local --job <job-name> | ||
| ``` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
|
|
||
| # GitLab CI Local (gitlab-ci-local) | ||
|
|
||
| Installs gitlab-ci-local CLI for running GitLab CI/CD pipelines locally | ||
|
|
||
| ## Example Usage | ||
|
|
||
| ```json | ||
| "features": { | ||
| "ghcr.io/rosstaco/devcontainer-features/gitlab-ci-local:1": {} | ||
| } | ||
| ``` | ||
|
|
||
| ## Options | ||
|
|
||
| | Options Id | Description | Type | Default Value | | ||
| |-----|-----|-----|-----| | ||
| | version | Version of gitlab-ci-local to install. Use 'latest' or a specific version like '4.67.0' | string | latest | | ||
|
|
||
| ## About | ||
|
|
||
| Tired of pushing to test your `.gitlab-ci.yml`? `gitlab-ci-local` lets you run GitLab CI/CD pipelines locally as a shell executor or docker executor. | ||
|
|
||
| For more information, see: https://github.com/firecow/gitlab-ci-local | ||
|
|
||
| ## How It Works | ||
|
|
||
| 1. **Downloads the binary** from [firecow/gitlab-ci-local](https://github.com/firecow/gitlab-ci-local) GitHub releases | ||
| 2. **Installs to** `/usr/local/bin/gitlab-ci-local` | ||
| 3. **Supports** both `amd64` and `arm64` architectures | ||
|
|
||
| ## Usage | ||
|
|
||
| Run a pipeline locally from a project with a `.gitlab-ci.yml`: | ||
|
|
||
| ```bash | ||
| gitlab-ci-local | ||
| ``` | ||
|
|
||
| Run a specific job: | ||
|
|
||
| ```bash | ||
| gitlab-ci-local --job <job-name> | ||
| ``` | ||
|
|
||
|
|
||
| --- | ||
|
|
||
| _Note: This file was auto-generated from the [devcontainer-feature.json](https://github.com/rosstaco/devcontainer-features/blob/main/src/gitlab-ci-local/devcontainer-feature.json). Add additional notes to a `NOTES.md`._ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| { | ||
| "id": "gitlab-ci-local", | ||
| "version": "1.0.0", | ||
| "name": "GitLab CI Local", | ||
| "description": "Installs gitlab-ci-local CLI for running GitLab CI/CD pipelines locally", | ||
| "documentationURL": "https://github.com/rosstaco/devcontainer-features/tree/main/src/gitlab-ci-local", | ||
| "options": { | ||
| "version": { | ||
| "type": "string", | ||
| "proposals": [ | ||
| "latest" | ||
| ], | ||
| "default": "latest", | ||
| "description": "Version of gitlab-ci-local to install. Use 'latest' or a specific version like '4.67.0'" | ||
| } | ||
| }, | ||
| "customizations": { | ||
| "vscode": { | ||
| "settings": { | ||
| "github.copilot.chat.codeGeneration.instructions": [ | ||
| { | ||
| "text": "This dev container includes `gitlab-ci-local`, which is pre-installed and available on the `PATH`. Use it to run GitLab CI/CD pipelines locally." | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| }, | ||
| "installsAfter": [ | ||
| "ghcr.io/devcontainers/features/common-utils" | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| #!/bin/bash | ||
| set -e | ||
|
|
||
| # GitLab CI Local installation script for devcontainer features | ||
| # https://github.com/firecow/gitlab-ci-local | ||
|
|
||
| CLI_VERSION="${VERSION:-latest}" | ||
|
|
||
| # Colors for output | ||
| RED='\033[0;31m' | ||
| GREEN='\033[0;32m' | ||
| NC='\033[0m' # No Color | ||
|
|
||
| if [ "$(id -u)" -ne 0 ]; then | ||
| echo -e "${RED}Script must be run as root. Use sudo, su, or add \"USER root\" to your Dockerfile before running this script.${NC}" | ||
| exit 1 | ||
| fi | ||
|
|
||
| apt_get_update() { | ||
| if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then | ||
| echo "Running apt-get update..." | ||
| apt-get update -y | ||
| fi | ||
| } | ||
|
|
||
| # Checks if packages are installed and installs them if not | ||
| check_packages() { | ||
| if ! dpkg -s "$@" > /dev/null 2>&1; then | ||
| apt_get_update | ||
| apt-get -y install --no-install-recommends "$@" | ||
| fi | ||
|
Comment on lines
+28
to
+31
|
||
| } | ||
|
|
||
| download_from_github() { | ||
| local release_url=$1 | ||
| local filename=$2 | ||
| echo "Downloading gitlab-ci-local from ${release_url}..." | ||
|
|
||
| mkdir -p /tmp/gitlab-ci-local | ||
| pushd /tmp/gitlab-ci-local | ||
| wget --show-progress --progress=dot:giga "${release_url}" | ||
| tar -xzf /tmp/gitlab-ci-local/"${filename}" | ||
| mv gitlab-ci-local /usr/local/bin/gitlab-ci-local | ||
| popd | ||
| rm -rf /tmp/gitlab-ci-local | ||
| } | ||
|
|
||
| install_using_github() { | ||
| check_packages wget tar ca-certificates git | ||
| echo "Finished setting up dependencies" | ||
|
|
||
| arch=$(dpkg --print-architecture) | ||
| if [ "${arch}" != "amd64" ] && [ "${arch}" != "arm64" ]; then | ||
| echo -e "${RED}Unsupported architecture: ${arch}${NC}" >&2 | ||
| echo -e "${RED}Only amd64 and arm64 are supported.${NC}" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| local cli_filename="gitlab-ci-local-linux-${arch}.tar.gz" | ||
| echo "Installing gitlab-ci-local for ${arch} architecture: ${cli_filename}" | ||
|
|
||
| if [ "${CLI_VERSION}" = "latest" ]; then | ||
| download_from_github "https://github.com/firecow/gitlab-ci-local/releases/latest/download/${cli_filename}" "${cli_filename}" | ||
| else | ||
| download_from_github "https://github.com/firecow/gitlab-ci-local/releases/download/${CLI_VERSION}/${cli_filename}" "${cli_filename}" | ||
|
Comment on lines
+41
to
+65
|
||
| fi | ||
| } | ||
|
|
||
| echo -e "${GREEN}Installing gitlab-ci-local...${NC}" | ||
|
|
||
| install_using_github | ||
|
|
||
| # Set executable permission | ||
| chmod +x /usr/local/bin/gitlab-ci-local | ||
|
|
||
| # Verify installation | ||
| if ! command -v gitlab-ci-local &> /dev/null; then | ||
| echo -e "${RED}gitlab-ci-local installation failed - command not found in PATH${NC}" | ||
| exit 1 | ||
| fi | ||
|
|
||
| INSTALLED_VERSION=$(gitlab-ci-local --version 2>&1 || true) | ||
| echo -e "${GREEN}gitlab-ci-local installed successfully: ${INSTALLED_VERSION}${NC}" | ||
| echo "" | ||
| echo "The 'gitlab-ci-local' command is now available." | ||
| echo "For more information: https://github.com/firecow/gitlab-ci-local" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| ## Usage | ||
|
|
||
| After installation, the `dumpty` command will be available: | ||
|
|
||
| ```bash | ||
| dumpty --help | ||
| dumpty --version | ||
| ``` | ||
|
|
||
| ## Notes | ||
|
|
||
| This feature installs prompty-dumpty system-wide using pip3 with the `--break-system-packages` flag, which is appropriate for containerized development environments. Python 3 is assumed to be present in the base image. | ||
|
|
||
| For more information about prompty-dumpty, visit: https://pypi.org/project/prompty-dumpty/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| { | ||
| "version": { | ||
| "image": "mcr.microsoft.com/devcontainers/base:ubuntu", | ||
| "features": { | ||
| "gitlab-ci-local": { | ||
| "version": "4.67.0" | ||
| } | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| #!/bin/bash | ||
|
|
||
| # This test file will be executed against an auto-generated devcontainer.json that | ||
| # includes the 'gitlab-ci-local' Feature with no options. | ||
| # | ||
| # Thus, the value of all options will fall back to the default value in the | ||
| # Feature's 'devcontainer-feature.json'. | ||
| # | ||
| # These scripts are run as 'root' by default. Although that can be changed | ||
| # with the '--remote-user' flag. | ||
|
|
||
| set -e | ||
|
|
||
| # Optional: Import test library bundled with the devcontainer CLI | ||
| source dev-container-features-test-lib | ||
|
|
||
| # Feature-specific tests | ||
| check "gitlab-ci-local is executable" command -v gitlab-ci-local | ||
|
|
||
| check "gitlab-ci-local binary exists" test -x /usr/local/bin/gitlab-ci-local | ||
|
|
||
| check "gitlab-ci-local version command works" bash -c "gitlab-ci-local --version 2>&1 | grep -q '[0-9]\+\.[0-9]\+\.[0-9]\+'" | ||
|
|
||
| # Report results | ||
| reportResults |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| #!/bin/bash | ||
|
|
||
| # This test verifies that a specific version can be installed | ||
|
|
||
| set -e | ||
|
|
||
| source dev-container-features-test-lib | ||
|
|
||
| check "gitlab-ci-local is executable" command -v gitlab-ci-local | ||
|
|
||
| check "gitlab-ci-local version command works" bash -c "gitlab-ci-local --version 2>&1 | grep -q '[0-9]\+\.[0-9]\+\.[0-9]\+'" | ||
|
|
||
| check "specific version 4.67.0 installed" bash -c "gitlab-ci-local --version 2>&1 | grep -q '4\.67\.0'" | ||
|
|
||
| reportResults |
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.
apt_get_updateusesfind /var/lib/apt/lists/*underset -e. On images where the glob doesn't match (or lists dir is empty),findcan exit non-zero and abort the install script beforeapt-get updateruns. Use a safer emptiness check that doesn't rely on a glob (e.g.,find /var/lib/apt/lists -maxdepth 1 -type f | wc -l,ls -A /var/lib/apt/lists, or guard errors with2>/dev/null || true).