diff --git a/breaking/README.md b/breaking/README.md index c7247e1..df6e253 100644 --- a/breaking/README.md +++ b/breaking/README.md @@ -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 diff --git a/breaking/action.yml b/breaking/action.yml index 655db76..9a4966c 100644 --- a/breaking/action.yml +++ b/breaking/action.yml @@ -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 @@ -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 @@ -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) @@ -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 diff --git a/lint/README.md b/lint/README.md index 16d2a38..0ed29d7 100644 --- a/lint/README.md +++ b/lint/README.md @@ -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 diff --git a/lint/action.yml b/lint/action.yml index 6b2414f..5d0bc22 100644 --- a/lint/action.yml +++ b/lint/action.yml @@ -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 @@ -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) @@ -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