Skip to content

Commit 8a460b9

Browse files
committed
refactor: cleanup github actions workflows
1 parent c55b110 commit 8a460b9

7 files changed

Lines changed: 143 additions & 47 deletions

File tree

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: 'Composer Install'
2+
description: 'Restore the Composer download cache and install dependencies for a given working directory'
3+
inputs:
4+
php-version:
5+
description: 'PHP version (used in the cache key)'
6+
required: true
7+
dependencies:
8+
description: 'Dependency resolution strategy (locked/lowest/highest)'
9+
required: false
10+
default: 'locked'
11+
working-directory:
12+
description: 'Working directory for composer operations'
13+
required: false
14+
default: '.'
15+
cache-key-suffix:
16+
description: 'Additional suffix for cache key'
17+
required: false
18+
default: ''
19+
composer-file:
20+
description: 'Path to composer.lock file for cache key'
21+
required: false
22+
default: '**/composer.lock'
23+
24+
runs:
25+
using: "composite"
26+
steps:
27+
- name: "Get Composer Cache Directory"
28+
id: composer-cache
29+
shell: bash
30+
working-directory: ${{ inputs.working-directory }}
31+
run: |
32+
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
33+
34+
- name: "Cache Composer dependencies"
35+
uses: "actions/cache@v4"
36+
with:
37+
path: "${{ steps.composer-cache.outputs.dir }}"
38+
key: "php-${{ inputs.php-version }}-${{ inputs.dependencies }}-composer${{ inputs.cache-key-suffix }}-${{ hashFiles(inputs.composer-file) }}"
39+
restore-keys: |
40+
php-${{ inputs.php-version }}-${{ inputs.dependencies }}-composer${{ inputs.cache-key-suffix }}-
41+
42+
- name: "Install lowest dependencies"
43+
if: ${{ inputs.dependencies == 'lowest' }}
44+
shell: bash
45+
working-directory: ${{ inputs.working-directory }}
46+
run: "composer update --prefer-lowest --no-interaction --no-progress"
47+
48+
- name: "Install highest dependencies"
49+
if: ${{ inputs.dependencies == 'highest' }}
50+
shell: bash
51+
working-directory: ${{ inputs.working-directory }}
52+
run: "composer update --no-interaction --no-progress"
53+
54+
- name: "Install locked dependencies"
55+
if: ${{ inputs.dependencies == 'locked' }}
56+
shell: bash
57+
working-directory: ${{ inputs.working-directory }}
58+
run: "composer install --no-interaction --no-progress"

.github/actions/setup-php-env/action.yml

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,18 @@ inputs:
5151
description: 'Space-separated list of PHP extensions to install via PIE (e.g., "flow-php/pg-query-ext:1.x-dev")'
5252
required: false
5353
default: ''
54+
extra-working-directory:
55+
description: 'Optional additional Composer project to install (e.g. "web/landing"). Left empty to skip.'
56+
required: false
57+
default: ''
58+
extra-cache-key-suffix:
59+
description: 'Cache key suffix for the extra working directory'
60+
required: false
61+
default: ''
62+
extra-composer-file:
63+
description: 'composer.lock path (for the cache key) of the extra working directory'
64+
required: false
65+
default: '**/composer.lock'
5466

5567
runs:
5668
using: "composite"
@@ -90,35 +102,22 @@ runs:
90102
sudo pie install "$ext"
91103
done
92104
93-
- name: "Get Composer Cache Directory"
94-
id: composer-cache
95-
shell: bash
96-
working-directory: ${{ inputs.working-directory }}
97-
run: |
98-
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
99-
100-
- name: "Cache Composer dependencies"
101-
uses: "actions/cache@v4"
105+
- name: "Install Composer dependencies"
106+
if: ${{ inputs.install-dependencies == 'true' }}
107+
uses: "./.github/actions/composer-install"
102108
with:
103-
path: "${{ steps.composer-cache.outputs.dir }}"
104-
key: "php-${{ inputs.php-version }}-${{ inputs.dependencies }}-composer${{ inputs.cache-key-suffix }}-${{ hashFiles(inputs.composer-file) }}"
105-
restore-keys: |
106-
php-${{ inputs.php-version }}-${{ inputs.dependencies }}-composer${{ inputs.cache-key-suffix }}-
107-
108-
- name: "Install lowest dependencies"
109-
if: ${{ inputs.dependencies == 'lowest' && inputs.install-dependencies == 'true' }}
110-
shell: bash
111-
working-directory: ${{ inputs.working-directory }}
112-
run: "composer update --prefer-lowest --no-interaction --no-progress"
109+
php-version: "${{ inputs.php-version }}"
110+
dependencies: "${{ inputs.dependencies }}"
111+
working-directory: "${{ inputs.working-directory }}"
112+
cache-key-suffix: "${{ inputs.cache-key-suffix }}"
113+
composer-file: "${{ inputs.composer-file }}"
113114

114-
- name: "Install highest dependencies"
115-
if: ${{ inputs.dependencies == 'highest' && inputs.install-dependencies == 'true' }}
116-
shell: bash
117-
working-directory: ${{ inputs.working-directory }}
118-
run: "composer update --no-interaction --no-progress"
119-
120-
- name: "Install locked dependencies"
121-
if: ${{ inputs.dependencies == 'locked' && inputs.install-dependencies == 'true' }}
122-
shell: bash
123-
working-directory: ${{ inputs.working-directory }}
124-
run: "composer install --no-interaction --no-progress"
115+
- name: "Install extra Composer dependencies"
116+
if: ${{ inputs.install-dependencies == 'true' && inputs.extra-working-directory != '' }}
117+
uses: "./.github/actions/composer-install"
118+
with:
119+
php-version: "${{ inputs.php-version }}"
120+
dependencies: "${{ inputs.dependencies }}"
121+
working-directory: "${{ inputs.extra-working-directory }}"
122+
cache-key-suffix: "${{ inputs.extra-cache-key-suffix }}"
123+
composer-file: "${{ inputs.extra-composer-file }}"

.github/workflows/baseline.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,17 +127,16 @@ jobs:
127127
cache-key-suffix: "-website-phar"
128128
apt-packages: "build-essential autoconf automake libtool protobuf-compiler libprotobuf-c-dev"
129129
pie-extensions: "flow-php/pg-query-ext:1.x-dev"
130+
extra-working-directory: "web/landing"
131+
extra-cache-key-suffix: "-website"
132+
extra-composer-file: "web/landing/composer.lock"
130133

131134
- name: "Generate documentation"
132135
run: "just docs"
133136

134137
- name: "Build latest version Flow Phar for playground"
135138
run: "just phar"
136139

137-
- name: "Install Landing dependencies"
138-
run: "composer install --no-interaction --no-progress "
139-
working-directory: "web/landing"
140-
141140
- name: "Build"
142141
run: "composer build"
143142
env:

.github/workflows/job-arrow-extension.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,10 @@ jobs:
9292
php -m | grep arrow
9393
9494
- name: Install Composer Dependencies
95-
run: composer install --no-interaction --no-progress
95+
uses: ./.github/actions/composer-install
96+
with:
97+
php-version: ${{ matrix.php }}
98+
dependencies: locked
9699

97100
- name: Run Parquet Integration Tests with Arrow
98101
run: just test --testsuite=lib-parquet-integration

.github/workflows/job-static-analyze.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,11 @@ jobs:
2727
php-version: "${{ matrix.php-version }}"
2828
dependencies: "${{ matrix.dependencies }}"
2929
coverage: "none"
30+
extra-working-directory: "web/landing"
31+
extra-cache-key-suffix: "-website"
32+
extra-composer-file: "web/landing/composer.lock"
3033

31-
- name: "Install web/landing dependencies"
32-
run: "composer install --no-interaction --no-progress"
33-
working-directory: "web/landing"
34-
35-
- name: "Static Analyze (Mago)"
34+
- name: "Static Analyze"
3635
run: "just analyze"
3736

3837
- name: "Install actionlint + zizmor"

.github/workflows/monorepo-split.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,33 @@ jobs:
134134
with:
135135
persist-credentials: false
136136

137+
- name: "Ensure target repository has a 1.x branch"
138+
env:
139+
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
140+
SPLIT_REPOSITORY: ${{ matrix.package.split_repository }}
141+
run: |
142+
set -euo pipefail
143+
remote="https://x-access-token:${ACCESS_TOKEN}@github.com/flow-php/${SPLIT_REPOSITORY}.git"
144+
145+
if [ -n "$(git ls-remote --heads "$remote" 1.x)" ]; then
146+
echo "flow-php/${SPLIT_REPOSITORY} already has a 1.x branch — nothing to do."
147+
exit 0
148+
fi
149+
150+
echo "flow-php/${SPLIT_REPOSITORY} has no 1.x branch — creating an empty one to bootstrap the split."
151+
tmp="$(mktemp -d)"
152+
git clone "$remote" "$tmp"
153+
git -C "$tmp" \
154+
-c user.name="norberttech" \
155+
-c user.email="norbert@orzechowicz.pl" \
156+
checkout --orphan 1.x
157+
git -C "$tmp" \
158+
-c user.name="norberttech" \
159+
-c user.email="norbert@orzechowicz.pl" \
160+
commit --allow-empty -m "Initialize repository"
161+
git -C "$tmp" push origin 1.x
162+
rm -rf "$tmp"
163+
137164
# no tag
138165
-
139166
if: "!startsWith(github.ref, 'refs/tags/')"

src/bridge/phpstan/types/.github/workflows/readonly.yaml

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,25 @@ on:
44
pull_request_target:
55
types: [opened]
66

7+
permissions: {}
8+
79
jobs:
810
run:
911
runs-on: ubuntu-latest
12+
permissions:
13+
pull-requests: write # Required to comment on and close the PR.
1014
steps:
11-
- uses: superbrothers/close-pull-request@v3
12-
with:
13-
comment: |
14-
Hi, thank you for your contribution.
15-
Unfortunately, this repository is read-only. It's a split from our main monorepo repository.
16-
In order to proceed with this PR please open it against https://github.com/flow-php/flow repository.
17-
Thank you.
15+
- name: Close pull request
16+
env:
17+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18+
GH_REPO: ${{ github.repository }}
19+
PR_NUMBER: ${{ github.event.pull_request.number }}
20+
COMMENT: |
21+
Thanks for your contribution! We love it & really appreciate your effort!
22+
23+
However, you should instead open your PR on the main monorepo repository:
24+
https://github.com/flow-php/flow
25+
26+
This repository is what we call a "subtree split": a read-only subset of that main monorepo repository.
27+
We're looking forward to your PR there!
28+
run: gh pr close "$PR_NUMBER" --comment "$COMMENT"

0 commit comments

Comments
 (0)