Skip to content

Commit c08e9d0

Browse files
committed
Smoke GitHub Actions runtime in tests workflow
1 parent 99515b4 commit c08e9d0

4 files changed

Lines changed: 121 additions & 0 deletions

File tree

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Setup Fast Forward GitHub Actions Runtime
2+
description: Resolve or globally install the fast-forward/github-actions command runtime.
3+
4+
inputs:
5+
version:
6+
description: Composer version constraint or branch for fast-forward/github-actions.
7+
required: false
8+
default: dev-main
9+
repository:
10+
description: Composer VCS repository used when installing branch refs.
11+
required: false
12+
default: https://github.com/php-fast-forward/github-actions
13+
prefer-local:
14+
description: Use a project-local vendor/bin/fast-forward-actions binary when available.
15+
required: false
16+
default: 'true'
17+
composer-home:
18+
description: COMPOSER_HOME used for global installs.
19+
required: false
20+
default: ''
21+
cache-dir:
22+
description: Composer cache directory used for global installs.
23+
required: false
24+
default: /tmp/composer-cache
25+
26+
outputs:
27+
command:
28+
description: Absolute fast-forward-actions command path.
29+
value: ${{ steps.resolve.outputs.command }}
30+
source:
31+
description: Where the command was resolved from.
32+
value: ${{ steps.resolve.outputs.source }}
33+
34+
runs:
35+
using: composite
36+
steps:
37+
- name: Resolve or install Fast Forward GitHub Actions runtime
38+
id: resolve
39+
shell: bash
40+
env:
41+
COMPOSER_AUTH: '{"github-oauth": {"github.com": "${{ github.token }}"} }'
42+
INPUT_CACHE_DIR: ${{ inputs.cache-dir }}
43+
INPUT_COMPOSER_HOME: ${{ inputs.composer-home }}
44+
INPUT_PREFER_LOCAL: ${{ inputs.prefer-local }}
45+
INPUT_REPOSITORY: ${{ inputs.repository }}
46+
INPUT_VERSION: ${{ inputs.version }}
47+
run: |
48+
set -euo pipefail
49+
50+
command_path=''
51+
command_source=''
52+
53+
if [ "${INPUT_PREFER_LOCAL}" = "true" ] && [ -x "${GITHUB_WORKSPACE}/vendor/bin/fast-forward-actions" ]; then
54+
command_path="${GITHUB_WORKSPACE}/vendor/bin/fast-forward-actions"
55+
command_source='project'
56+
elif command -v fast-forward-actions >/dev/null 2>&1; then
57+
command_path="$(command -v fast-forward-actions)"
58+
command_source='path'
59+
fi
60+
61+
if [ -z "${command_path}" ]; then
62+
composer_home="${INPUT_COMPOSER_HOME:-${RUNNER_TEMP}/fast-forward-composer-home}"
63+
mkdir -p "${composer_home}" "${INPUT_CACHE_DIR}"
64+
65+
export COMPOSER_HOME="${composer_home}"
66+
export COMPOSER_CACHE_DIR="${INPUT_CACHE_DIR}"
67+
68+
composer global config --no-plugins repositories.fast-forward-github-actions vcs "${INPUT_REPOSITORY}"
69+
composer global require --no-plugins --no-scripts --no-interaction --prefer-dist --no-progress "fast-forward/github-actions:${INPUT_VERSION}"
70+
71+
command_path="${composer_home}/vendor/bin/fast-forward-actions"
72+
command_source='composer-global'
73+
74+
echo "${composer_home}/vendor/bin" >> "${GITHUB_PATH}"
75+
echo "COMPOSER_HOME=${composer_home}" >> "${GITHUB_ENV}"
76+
fi
77+
78+
if [ ! -x "${command_path}" ]; then
79+
echo "::error::Resolved fast-forward-actions command is not executable: ${command_path}"
80+
exit 1
81+
fi
82+
83+
echo "FAST_FORWARD_ACTIONS_BIN=${command_path}" >> "${GITHUB_ENV}"
84+
echo "command=${command_path}" >> "${GITHUB_OUTPUT}"
85+
echo "source=${command_source}" >> "${GITHUB_OUTPUT}"
86+
"${command_path}" --version

.github/actions/php/detect-project/action.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,16 @@ runs:
3333
run: |
3434
set -euo pipefail
3535
36+
if [ -n "${FAST_FORWARD_ACTIONS_BIN:-}" ]; then
37+
"${FAST_FORWARD_ACTIONS_BIN}" php:detect-project --github-output
38+
exit 0
39+
fi
40+
41+
if command -v fast-forward-actions >/dev/null 2>&1; then
42+
fast-forward-actions php:detect-project --github-output
43+
exit 0
44+
fi
45+
3646
composer_json=false
3747
docs_source=false
3848
php_files=false

.github/actions/php/resolve-version/action.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@ runs:
2222
id: resolve
2323
shell: bash
2424
run: |
25+
if [ -n "${FAST_FORWARD_ACTIONS_BIN:-}" ]; then
26+
"${FAST_FORWARD_ACTIONS_BIN}" php:resolve-version --github-output
27+
exit 0
28+
fi
29+
30+
if command -v fast-forward-actions >/dev/null 2>&1; then
31+
fast-forward-actions php:resolve-version --github-output
32+
exit 0
33+
fi
34+
2535
python3 <<'PY'
2636
from __future__ import annotations
2737

.github/workflows/tests.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ on:
88
required: false
99
type: string
1010
default: ^1.0
11+
github-actions-version:
12+
description: Composer version constraint or branch used when globally installing fast-forward/github-actions.
13+
required: false
14+
type: string
15+
default: dev-main
1116
min-coverage:
1217
description: Minimum line coverage percentage enforced by dev-tools tests.
1318
required: false
@@ -30,6 +35,11 @@ on:
3035
required: false
3136
type: string
3237
default: ^1.0
38+
github-actions-version:
39+
description: Composer version constraint or branch used when globally installing fast-forward/github-actions.
40+
required: false
41+
type: string
42+
default: dev-main
3343
min-coverage:
3444
description: Minimum line coverage percentage enforced by dev-tools tests.
3545
required: false
@@ -118,6 +128,11 @@ jobs:
118128
sparse-checkout: |
119129
.github/actions
120130
131+
- name: Setup Fast Forward GitHub Actions runtime
132+
uses: ./.fast-forward-actions/.github/actions/github-actions/setup
133+
with:
134+
version: ${{ inputs.github-actions-version || vars.FAST_FORWARD_GITHUB_ACTIONS_VERSION || 'dev-main' }}
135+
121136
- name: Resolve workflow PHP version
122137
id: resolve
123138
uses: ./.fast-forward-actions/.github/actions/php/resolve-version

0 commit comments

Comments
 (0)