Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion breaking/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,13 @@ with:

(optional)

Path to the EasyP configuration file.
Path to the EasyP configuration file, relative to the repository root.

The action places the flag for the EasyP version in the image. EasyP v0 and
early v1 nightlies receive the global `--cfg` flag, which also applies to
`mod download`. Later v1 builds receive `--config` after the command, and
`mod download` reads `protobuf.mod`/`protobuf.lock` without it. With v1, pass
a policy file such as `easyp.yaml` or `ci.easyp.yaml`, not `easyp.gen.yaml`.

```yaml
uses: easyp-tech/actions/breaking@v1
Expand Down
30 changes: 24 additions & 6 deletions breaking/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,27 @@ runs:
shell: bash
run: docker pull ghcr.io/easyp-tech/easyp:${{ inputs.version }}

- name: Detect config flag placement
id: config-flag
shell: bash
run: |
# EasyP v0 and early v1 nightlies take a global --cfg; later v1 builds
# take --config after the command and reject the global flag.
PLACEMENT=none
if [ -n "${{ inputs.config }}" ]; then
PLACEMENT=global
HELP=$(docker run --rm ghcr.io/easyp-tech/easyp:${{ inputs.version }} breaking --help 2>&1 || true)
if grep -qE -- '(^|[[:space:]])--config([[:space:]=]|$)' <<<"$HELP"; then
PLACEMENT=command
fi
fi
echo "placement=$PLACEMENT" >> "$GITHUB_OUTPUT"

- name: Download dependencies
shell: bash
run: |
GLOBAL_ARGS=""
if [ -n "${{ inputs.config }}" ]; then
if [ "${{ steps.config-flag.outputs.placement }}" = "global" ]; then
GLOBAL_ARGS="--cfg=/workspace/${{ inputs.config }}"
fi

Expand All @@ -56,9 +72,11 @@ runs:
)

GLOBAL_ARGS=()
if [ -n "${{ inputs.config }}" ]; then
GLOBAL_ARGS+=( "--cfg=/workspace/${{ inputs.config }}" )
fi
CONFIG_ARGS=()
case "${{ steps.config-flag.outputs.placement }}" in
global) GLOBAL_ARGS+=( "--cfg=/workspace/${{ inputs.config }}" ) ;;
command) CONFIG_ARGS+=( "--config=/workspace/${{ inputs.config }}" ) ;;
esac

echo "Fetching branches and tags from origin"
git fetch --prune --tags origin "+refs/heads/*:refs/remotes/origin/*" >/dev/null 2>&1
Expand All @@ -80,7 +98,7 @@ runs:

BASE_GLOBAL_ARGS=( "${GLOBAL_ARGS[@]}" )
GLOBAL_ARGS=( "${BASE_GLOBAL_ARGS[@]}" "--format=json" )
COMMAND_ARGS=( breaking "--against=$RESOLVED_AGAINST" "--path=${{ inputs.directory }}" )
COMMAND_ARGS=( breaking "${CONFIG_ARGS[@]}" "--against=$RESOLVED_AGAINST" "--path=${{ inputs.directory }}" )

STDOUT_FILE=$(mktemp)
STDERR_FILE=$(mktemp)
Expand All @@ -103,7 +121,7 @@ runs:
run_easyp
if [ "$EXIT_CODE" -ne 0 ] && grep -q 'flag provided but not defined: -format' "$STDERR_FILE"; then
GLOBAL_ARGS=( "${BASE_GLOBAL_ARGS[@]}" )
COMMAND_ARGS=( breaking "--format=json" "--against=$RESOLVED_AGAINST" "--path=${{ inputs.directory }}" )
COMMAND_ARGS=( breaking "${CONFIG_ARGS[@]}" "--format=json" "--against=$RESOLVED_AGAINST" "--path=${{ inputs.directory }}" )
run_easyp
fi

Expand Down
8 changes: 7 additions & 1 deletion lint/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,13 @@ with:

(optional)

Path to the EasyP configuration file.
Path to the EasyP configuration file, relative to the repository root.

The action places the flag for the EasyP version in the image. EasyP v0 and
early v1 nightlies receive the global `--cfg` flag, which also applies to
`mod download`. Later v1 builds receive `--config` after the command, and
`mod download` reads `protobuf.mod`/`protobuf.lock` without it. With v1, pass
a policy file such as `easyp.yaml` or `ci.easyp.yaml`, not `easyp.gen.yaml`.

```yaml
uses: easyp-tech/actions/lint@v1
Expand Down
30 changes: 24 additions & 6 deletions lint/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,27 @@ runs:
shell: bash
run: docker pull ghcr.io/easyp-tech/easyp:${{ inputs.version }}

- name: Detect config flag placement
id: config-flag
shell: bash
run: |
# EasyP v0 and early v1 nightlies take a global --cfg; later v1 builds
# take --config after the command and reject the global flag.
PLACEMENT=none
if [ -n "${{ inputs.config }}" ]; then
PLACEMENT=global
HELP=$(docker run --rm ghcr.io/easyp-tech/easyp:${{ inputs.version }} lint --help 2>&1 || true)
if grep -qE -- '(^|[[:space:]])--config([[:space:]=]|$)' <<<"$HELP"; then
PLACEMENT=command
fi
fi
echo "placement=$PLACEMENT" >> "$GITHUB_OUTPUT"

- name: Download dependencies
shell: bash
run: |
GLOBAL_ARGS=""
if [ -n "${{ inputs.config }}" ]; then
if [ "${{ steps.config-flag.outputs.placement }}" = "global" ]; then
GLOBAL_ARGS="--cfg=/workspace/${{ inputs.config }}"
fi

Expand All @@ -52,13 +68,15 @@ runs:
)

GLOBAL_ARGS=()
if [ -n "${{ inputs.config }}" ]; then
GLOBAL_ARGS+=( "--cfg=/workspace/${{ inputs.config }}" )
fi
CONFIG_ARGS=()
case "${{ steps.config-flag.outputs.placement }}" in
global) GLOBAL_ARGS+=( "--cfg=/workspace/${{ inputs.config }}" ) ;;
command) CONFIG_ARGS+=( "--config=/workspace/${{ inputs.config }}" ) ;;
esac

BASE_GLOBAL_ARGS=( "${GLOBAL_ARGS[@]}" )
GLOBAL_ARGS=( "${BASE_GLOBAL_ARGS[@]}" "--format=json" )
COMMAND_ARGS=( lint "--path=${{ inputs.directory }}" )
COMMAND_ARGS=( lint "${CONFIG_ARGS[@]}" "--path=${{ inputs.directory }}" )

STDOUT_FILE=$(mktemp)
STDERR_FILE=$(mktemp)
Expand All @@ -81,7 +99,7 @@ runs:
run_easyp
if [ "$EXIT_CODE" -ne 0 ] && grep -q 'flag provided but not defined: -format' "$STDERR_FILE"; then
GLOBAL_ARGS=( "${BASE_GLOBAL_ARGS[@]}" )
COMMAND_ARGS=( lint "--format=json" "--path=${{ inputs.directory }}" )
COMMAND_ARGS=( lint "${CONFIG_ARGS[@]}" "--format=json" "--path=${{ inputs.directory }}" )
run_easyp
fi

Expand Down