This document provides instructions for testing the cr.sh
script locally to verify that it's working correctly, especially after fixes to the parameter handling.
- Git repository with Helm charts
- Docker (optional, for testing in an isolated environment)
- GitHub CLI (
gh
) (optional, only needed for GitHub release operations) - Helm installed (optional, as the script can install it)
Always enable debug logging when testing:
# Method 1: Use environment variable
DEBUG=true ./cr.sh --oci-registry ghcr.io --oci-path mypath --oci-username myuser
# Method 2: Use command-line flag
./cr.sh --debug --oci-registry ghcr.io --oci-path mypath --oci-username myuser
Test the parameters that were previously causing issues:
# Test with all required parameters
./cr.sh --debug \
--oci-registry ghcr.io \
--oci-path myorg \
--oci-username myuser \
--charts-dir stable \
--version v3.13.2 \
--mark-as-latest true
# Expected result: Script should proceed past parameter validation
# Look for debug logs showing each parameter is properly set
Test the case where you want to skip OCI login (which makes oci_username
optional):
./cr.sh --debug \
--oci-registry ghcr.io \
--oci-path myorg \
--skip-oci-login true \
--charts-dir stable
Use dry run mode to test without making actual changes:
DRY_RUN=true ./cr.sh --debug \
--oci-registry ghcr.io \
--oci-path myorg \
--oci-username myuser \
--charts-dir stable
For isolated testing, you can use Docker:
# Create a temporary Dockerfile
cat > Dockerfile.test << EOF
FROM ubuntu:latest
RUN apt-get update && \
apt-get install -y git curl
WORKDIR /app
COPY cr.sh /app/
RUN chmod +x /app/cr.sh
ENV DEBUG=true
ENV DRY_RUN=true
ENV GITHUB_TOKEN=dummy_token
ENV OCI_PASSWORD=dummy_password
CMD ["/app/cr.sh", "--oci-registry", "ghcr.io", "--oci-path", "myorg", "--oci-username", "myuser", "--charts-dir", "stable"]
EOF
# Build and run
docker build -t cr-test -f Dockerfile.test .
docker run cr-test
You can test GitHub Actions locally using act, a tool that allows you to run your GitHub Actions workflows locally.
There are several ways to install act:
macOS (using Homebrew):
brew install act
Linux (using Homebrew):
brew install act
Using Go:
go install github.com/nektos/act@latest
Manual installation:
- Download the latest release from https://github.com/nektos/act/releases
- Extract and add to your PATH
Docker:
docker pull nektos/act
alias act='docker run -it -v $(pwd):/github/workspace -v /var/run/docker.sock:/var/run/docker.sock nektos/act'
- Create a test workflow file:
# .github/workflows/test.yml
name: Test Workflow
on: [push]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run helm-oci-charts-releaser
uses: ./
env:
DEBUG: true
with:
oci_registry: ghcr.io
oci_path: myorg
oci_username: myuser
oci_password: ${{ secrets.OCI_PASSWORD }}
charts_dir: stable
github_token: ${{ secrets.GITHUB_TOKEN }}
version: v3.13.2
mark_as_latest: true
- Run with dummy secrets:
act -s GITHUB_TOKEN=dummy -s OCI_PASSWORD=dummy
List all actions in workflows:
act -l
Run specific jobs:
act -j test
Run specific events:
act push
Use a specific runner image:
act -P ubuntu-latest=nektos/act-environments-ubuntu:18.04
Use the default micro image (faster but fewer dependencies):
act -P ubuntu-latest=catthehacker/ubuntu:act-latest
Bind your local Docker socket:
act --bind
Get verbose output:
act -v
- Error: No workflows found: Make sure your workflow file is in
.github/workflows/
- Resource constraints: Use
--container-daemon-socket /var/run/docker.sock
to use your host's Docker daemon - Missing secrets: Use
-s SECRET_NAME=value
to pass secrets - Missing environment variables: Use
-e ENV_NAME=value
to pass environment variables - Docker in Docker issues: Use
--bind
to bind your local Docker socket
- Missing GITHUB_TOKEN: Set with
export GITHUB_TOKEN=dummy
for testing - Missing OCI_PASSWORD: Set with
export OCI_PASSWORD=dummy
for testing - Git issues: Make sure you're running in a git repository with proper permissions
- Chart detection: If no charts are found, check your charts directory structure
- GitHub CLI not installed: If you're getting errors about
gh
not found, you can:- Install GitHub CLI from https://cli.github.com/
- Use
--skip-gh-release true
to skip GitHub release operations - Set
DRY_RUN=true
to simulate operations without executing them