Skip to content

Commit 560b002

Browse files
committed
Updated assemble.sh to use Drupal version for project SHA + PHP 8.4 in CI.
1 parent 86d96b0 commit 560b002

File tree

3 files changed

+83
-50
lines changed

3 files changed

+83
-50
lines changed

.devtools/assemble.sh

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,12 @@ set -eu
2121
# Variables (passed from environment; provided for reference only).
2222
#-------------------------------------------------------------------------------
2323

24-
# Drupal core version to use. If not provided - the latest stable version will be used.
25-
# Must be coupled with DRUPAL_PROJECT_SHA below.
26-
DRUPAL_VERSION="${DRUPAL_VERSION:-10}"
24+
# Drupal core version to use.
25+
DRUPAL_VERSION="${DRUPAL_VERSION:-11}"
2726

2827
# Commit SHA of the drupal-project to install custom core version. If not
29-
# provided - the latest version will be used.
30-
# Must be coupled with DRUPAL_VERSION above.
31-
DRUPAL_PROJECT_SHA="${DRUPAL_PROJECT_SHA:-10.x}"
28+
# provided - will be calculated from `$DRUPAL_VERSION` above.
29+
DRUPAL_PROJECT_SHA="${DRUPAL_PROJECT_SHA:-}"
3230

3331
# Repository for "drupal-composer/drupal-project" project.
3432
# May be overwritten to use forked repos that may have not been accepted
@@ -51,19 +49,23 @@ echo " 🏗️ ASSEMBLE "
5149
echo "==============================="
5250
echo
5351

52+
# Validate required variables.
53+
[ -z "${DRUPAL_VERSION}" ] && { fail "ERROR: DRUPAL_VERSION is not set."; exit 1; }
54+
[ -z "${DRUPAL_PROJECT_REPO}" ] && { fail "ERROR: DRUPAL_PROJECT_REPO is not set."; exit 1; }
55+
5456
# Make sure Composer doesn't run out of memory.
5557
export COMPOSER_MEMORY_LIMIT=-1
5658

5759
info "Validate tools."
58-
! command -v git >/dev/null && echo "ERROR: Git is required for this script to run." && exit 1
59-
! command -v php >/dev/null && echo "ERROR: PHP is required for this script to run." && exit 1
60-
! command -v composer >/dev/null && echo "ERROR: Composer (https://getcomposer.org/) is required for this script to run." && exit 1
61-
! command -v jq >/dev/null && echo "ERROR: jq (https://stedolan.github.io/jq/) is required for this script to run." && exit 1
60+
! command -v git >/dev/null && fail "ERROR: Git is required for this script to run." && exit 1
61+
! command -v php >/dev/null && fail "ERROR: PHP is required for this script to run." && exit 1
62+
! command -v composer >/dev/null && fail "ERROR: Composer (https://getcomposer.org/) is required for this script to run." && exit 1
63+
! command -v jq >/dev/null && fail "ERROR: jq (https://stedolan.github.io/jq/) is required for this script to run." && exit 1
6264
pass "Tools are valid."
6365

6466
# Extension name, taken from the .info file.
6567
extension="$(basename -s .info.yml -- ./*.info.yml)"
66-
[ "${extension}" == "*" ] && echo "ERROR: No .info.yml file found." && exit 1
68+
[ "${extension}" == "*" ] && fail "ERROR: No .info.yml file found." && exit 1
6769

6870
# Extension type.
6971
type=$(grep -q "type: theme" "${extension}.info.yml" && echo "themes" || echo "modules")
@@ -80,25 +82,23 @@ if [ -d "build" ]; then
8082
fi
8183

8284
info "Creating Drupal codebase."
83-
# Allow installing custom version of Drupal core from drupal-composer/drupal-project,
84-
# but only coupled with drupal-project SHA (required to get correct dependencies).
85-
if [ -n "${DRUPAL_VERSION:-}" ] && [ -n "${DRUPAL_PROJECT_SHA:-}" ]; then
86-
note "Initialising Drupal site from the scaffold repo ${DRUPAL_PROJECT_REPO} commit ${DRUPAL_PROJECT_SHA}."
87-
88-
# Clone Drupal core at the specific commit SHA.
89-
git clone -n "${DRUPAL_PROJECT_REPO}" "build"
90-
git --git-dir="build/.git" --work-tree="build" checkout "${DRUPAL_PROJECT_SHA}"
91-
rm -rf "build/.git" >/dev/null
92-
93-
note "Pin Drupal to a specific version ${DRUPAL_VERSION}."
94-
sed_opts=(-i) && [ "$(uname)" == "Darwin" ] && sed_opts=(-i '')
95-
sed "${sed_opts[@]}" 's|\(.*"drupal\/core"\): "\(.*\)",.*|\1: '"\"$DRUPAL_VERSION\",|" "build/composer.json"
96-
cat "build/composer.json"
97-
else
98-
note "Initialising Drupal site from the latest scaffold."
99-
# There are no releases in "drupal-composer/drupal-project", so have to use "@dev".
100-
composer create-project drupal-composer/drupal-project:@dev "build" --no-interaction --no-install
85+
86+
if [ -z "${DRUPAL_PROJECT_SHA:-}" ]; then
87+
DRUPAL_PROJECT_SHA="$(echo "${DRUPAL_VERSION}" | cut -d '.' -f 1 | cut -d '@' -f 1).x"
10188
fi
89+
90+
note "Initialising Drupal site from the scaffold repo ${DRUPAL_PROJECT_REPO} ref ${DRUPAL_PROJECT_SHA}."
91+
92+
# Clone Drupal project at the specific commit SHA.
93+
git clone -n "${DRUPAL_PROJECT_REPO}" "build"
94+
git --git-dir="build/.git" --work-tree="build" checkout "${DRUPAL_PROJECT_SHA}"
95+
rm -rf "build/.git" >/dev/null
96+
97+
note "Pinning Drupal to a specific version ${DRUPAL_VERSION}."
98+
sed_opts=(-i) && [ "$(uname)" == "Darwin" ] && sed_opts=(-i '')
99+
sed "${sed_opts[@]}" 's|\(.*"drupal\/core.*"\): "\(.*\)",.*|\1: '"\"~$DRUPAL_VERSION\",|" "build/composer.json"
100+
grep '"drupal/core-.*": "' "build/composer.json"
101+
102102
pass "Drupal codebase created."
103103

104104
info "Merging configuration from composer.dev.json."
@@ -148,7 +148,7 @@ if [ -f "package-lock.json" ]; then
148148
if [ -f ".nvmrc" ]; then nvm use || true; fi
149149
if [ ! -d "node_modules" ]; then npm ci; fi
150150

151-
echo "> Building front-end dependencies."
151+
note "Building front-end dependencies."
152152
if [ ! -f ".skip_npm_build" ]; then npm run build; fi
153153
pass "Front-end dependencies installed."
154154
fi
@@ -170,6 +170,6 @@ echo " 🏗 ASSEMBLE COMPLETE ✅ "
170170
echo "==============================="
171171
echo
172172
echo "> Next steps:"
173-
echo " .devtools/start.sh # Start the webserver"
173+
echo " .devtools/start.sh # Start the webserver"
174174
echo " .devtools/provision.sh # Provision the website"
175175
echo

.devtools/provision.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ echo -n "One-time login link: "
9494
drush -l "http://${WEBSERVER_HOST}:${WEBSERVER_PORT}" uli --no-browser
9595
echo
9696
echo "> Available commands:"
97-
echo " ahoy build # Rebuild"
98-
echo " ahoy lint # Check coding standards"
99-
echo " ahoy test # Run tests"
97+
echo " ahoy build # Rebuild"
98+
echo " ahoy lint # Check coding standards"
99+
echo " ahoy lint-fix # Fix coding standards"
100+
echo " ahoy test # Run tests"
100101
echo

.github/workflows/test.yml

Lines changed: 48 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,36 +17,68 @@ jobs:
1717
strategy:
1818
matrix:
1919
include:
20-
- name: test-php-8.2
20+
- name: test-php-8.2-d10-legacy
2121
php-version: 8.2
22-
drupal-version: stable
23-
drupal-project-sha: 10.x
22+
drupal-version: 10.2
2423

25-
- name: test-php-8.2-legacy
24+
- name: test-php-8.2-d10-stable
2625
php-version: 8.2
27-
drupal-version: 10.1
28-
drupal-project-sha: 10.x
26+
drupal-version: 10.3
2927

30-
- name: test-php-8.2-next
28+
- name: test-php-8.2-d10-canary
3129
php-version: 8.2
3230
drupal-version: 10@beta
33-
drupal-project-sha: 10.x
3431

35-
- name: test-php-8.3
32+
- name: test-php-8.3-d10-legacy
3633
php-version: 8.3
37-
drupal-version: stable
38-
drupal-project-sha: 10.x
34+
drupal-version: 10.2
3935

40-
- name: test-php-8.3-next
36+
- name: test-php-8.3-d10-stable
4137
php-version: 8.3
42-
drupal-version: 11@alpha
43-
drupal-project-sha: 11.x
38+
drupal-version: 10.3
4439

45-
name: ${{ matrix.name }}
40+
- name: test-php-8.3-d10-canary
41+
php-version: 8.3
42+
drupal-version: 10@beta
43+
44+
- name: test-php-8.4-d10-legacy
45+
php-version: 8.4
46+
drupal-version: 10.2
47+
48+
- name: test-php-8.4-d10-stable
49+
php-version: 8.4
50+
drupal-version: 10.3
51+
52+
- name: test-php-8.4-d10-canary
53+
php-version: 8.4
54+
drupal-version: 10@beta
55+
56+
- name: test-php-8.3-d11-legacy
57+
php-version: 8.3
58+
drupal-version: 11.0
59+
60+
- name: test-php-8.3-d11-stable
61+
php-version: 8.3
62+
drupal-version: 11.0
63+
64+
- name: test-php-8.3-d11-canary
65+
php-version: 8.3
66+
drupal-version: 11@beta
67+
68+
- name: test-php-8.4-d11-legacy
69+
php-version: 8.4
70+
drupal-version: 11.0
71+
72+
- name: test-php-8.4-d11-stable
73+
php-version: 8.4
74+
drupal-version: 11.0
75+
76+
- name: test-php-8.4-d11-canary
77+
php-version: 8.4
78+
drupal-version: 11@beta
4679

4780
env:
4881
DRUPAL_VERSION: ${{ matrix.drupal-version }}
49-
DRUPAL_PROJECT_SHA: ${{ matrix.drupal-project-sha }}
5082

5183
steps:
5284
- name: Checkout code

0 commit comments

Comments
 (0)