Skip to content

Commit

Permalink
Merge branch 'master' into website-v3
Browse files Browse the repository at this point in the history
# Conflicts:
#	docs/local-development/event-driven-functions.mdx
#	docs/runtimes/README.md
#	website/template/_redirects
  • Loading branch information
mnapoli committed Oct 9, 2023
2 parents 175177c + facbca8 commit 8ab21d3
Show file tree
Hide file tree
Showing 25 changed files with 741 additions and 365 deletions.
25 changes: 14 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,22 @@ jobs:
timeout-minutes: 15
strategy:
matrix:
php: [ '8.2', '8.1', '8.0' ]
php: [ '8.3', '8.2', '8.1', '8.0' ]
dependency-version: [ '' ]
platform-reqs: [ '' ]
include:
- php: '8.0'
dependency-version: '--prefer-lowest'
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
# Node is required by some tests
- uses: actions/setup-node@v1
- uses: actions/setup-node@v3
with:
node-version: 12
node-version: 18
# serverless is required by some tests
- name: Install serverless
run: npm i -g serverless
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
Expand All @@ -46,15 +49,15 @@ jobs:
name: PHPStan
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
php-version: '8.2'
tools: composer:v2, cs2pr
coverage: none
- name: Cache Composer dependencies
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.composer/cache
key: php-composer-locked-${{ hashFiles('composer.lock') }}
Expand All @@ -69,15 +72,15 @@ jobs:
name: PHP CodeSniffer
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
php-version: '8.2'
tools: composer:v2, cs2pr
coverage: none
- name: Cache Composer dependencies
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.composer/cache
key: php-composer-locked-${{ hashFiles('composer.lock') }}
Expand All @@ -95,7 +98,7 @@ jobs:
- uses: actions/setup-node@v3
with:
node-version: 18
- uses: actions/cache@v2
- uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }}
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/update-layer-versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,10 @@ on:
workflow_dispatch:
inputs:
release_url:
required: true
type: string
release_html_url:
required: true
type: string
release_name:
required: true
type: string

# Necessary to connect to AWS using OIDC
Expand All @@ -32,7 +29,7 @@ jobs:
ref: master

- name: Set AWS credentials
uses: aws-actions/configure-aws-credentials@v1
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: arn:aws:iam::534081306603:role/bref-github-actions
role-session-name: bref-github-actions
Expand All @@ -41,7 +38,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
php-version: '8.2'
tools: composer

- name: Install Composer dependencies
Expand All @@ -50,7 +47,7 @@ jobs:
- run: make layers.json

- name: Create Pull Request
uses: peter-evans/create-pull-request@v4
uses: peter-evans/create-pull-request@v5
with:
commit-message: Update layer versions
title: Update Lambda layers [${{ inputs.release_name }}](${{ inputs.release_html_url }})
Expand Down
11 changes: 6 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
"hollodotme/fast-cgi-client": "^3.0.1",
"nyholm/psr7": "^1.4.1",
"psr/container": "^1.0|^2.0",
"psr/http-message": "^1.0",
"psr/http-message": "^1.0|^2.0",
"psr/http-server-handler": "^1.0",
"riverline/multipart-parser": "^2.0.6",
"symfony/process": "^4.4|^5.0|^6.0"
"symfony/process": "^4.4|^5.0|^6.0|^7.0"
},
"require-dev": {
"async-aws/core": "^1.0",
Expand All @@ -40,9 +40,10 @@
"dms/phpunit-arraysubset-asserts": "^0.4",
"doctrine/coding-standard": "^8.0",
"guzzlehttp/guzzle": "^7.5",
"phpstan/phpstan": "^1.0",
"phpunit/phpunit": "^9.0",
"symfony/console": "^4.4|^5.0|^6.0"
"phpstan/phpstan": "^1.10.26",
"phpunit/phpunit": "^9.6.10",
"symfony/console": "^4.4|^5.0|^6.0|^7.0",
"symfony/yaml": "^4.4|^5.0|^6.0|^7.0"
},
"scripts": {
"test": [
Expand Down
36 changes: 20 additions & 16 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class ServerlessPlugin {
.filter(name => !name.startsWith('arm-'));
// Console runtimes must have a PHP version provided
this.runtimes = this.runtimes.filter(name => name !== 'console');
this.runtimes.push('php-80-console', 'php-81-console', 'php-82-console');
this.runtimes.push('php-80-console', 'php-81-console', 'php-82-console', 'php-83-console');

this.checkCompatibleRuntime();

Expand Down Expand Up @@ -197,23 +197,27 @@ class ServerlessPlugin {

const config = this.serverless.service;
const isArmGlobally = config.provider.architecture === 'arm64';

// Check provider config
if (this.runtimes.includes(config.provider.runtime || '')) {
config.provider.layers = includeBrefLayers(
config.provider.runtime,
config.provider.layers || [], // make sure it's an array
isArmGlobally,
);
config.provider.runtime = 'provided.al2';
}
const isBrefRuntimeGlobally = this.runtimes.includes(config.provider.runtime || '');

// Check functions config
for (const f of Object.values(config.functions || {})) {
if (f.runtime && this.runtimes.includes(f.runtime)) {
if (
(f.runtime && this.runtimes.includes(f.runtime)) ||
(!f.runtime && isBrefRuntimeGlobally)
) {
// The logic here is a bit custom:
// If there are layers on the function, we preserve them
let existingLayers = f.layers || []; // make sure it's an array
// Else, we merge with the layers defined at the root.
// Indeed, SF overrides the layers defined at the root with the ones defined on the function.
if (existingLayers.length === 0) {
// for some reason it's not always an array
existingLayers = Array.from(config.provider.layers || []);
}

f.layers = includeBrefLayers(
f.runtime,
f.layers || [], // make sure it's an array
f.runtime || config.provider.runtime,
existingLayers,
f.architecture === 'arm64' || (isArmGlobally && !f.architecture),
);
f.runtime = 'provided.al2';
Expand All @@ -224,9 +228,9 @@ class ServerlessPlugin {
for (const construct of Object.values(this.serverless.configurationInput.constructs || {})) {
if (construct.type !== 'queue' && construct.type !== 'webhook') continue;
const f = construct.type === 'queue' ? construct.worker : construct.authorizer;
if (f && f.runtime && this.runtimes.includes(f.runtime)) {
if (f && (f.runtime && this.runtimes.includes(f.runtime) || !f.runtime && isBrefRuntimeGlobally) ) {
f.layers = includeBrefLayers(
f.runtime,
f.runtime || config.provider.runtime,
f.layers || [], // make sure it's an array
f.architecture === 'arm64' || (isArmGlobally && !f.architecture),
);
Expand Down
Loading

0 comments on commit 8ab21d3

Please sign in to comment.