From 9ff741187e1de51984a5decafac742b31204454e Mon Sep 17 00:00:00 2001 From: Aaron Feledy Date: Thu, 19 Feb 2026 19:30:00 -0600 Subject: [PATCH 1/3] test: add backends example and leia test Adds test infrastructure for nginx backends feature (issue #5). This allows an nginx service to declare upstream backend services that it depends on and can proxy to. Tests will fail until the backends config option is implemented. --- .github/workflows/pr-nginx-tests.yml | 1 + examples/backends/.lando.yml | 27 ++++++++++++++ examples/backends/README.md | 52 +++++++++++++++++++++++++++ examples/backends/backend1/index.html | 1 + examples/backends/backend2/index.html | 1 + examples/backends/config/proxy.conf | 21 +++++++++++ examples/backends/index.html | 1 + 7 files changed, 104 insertions(+) create mode 100644 examples/backends/.lando.yml create mode 100644 examples/backends/README.md create mode 100644 examples/backends/backend1/index.html create mode 100644 examples/backends/backend2/index.html create mode 100644 examples/backends/config/proxy.conf create mode 100644 examples/backends/index.html diff --git a/.github/workflows/pr-nginx-tests.yml b/.github/workflows/pr-nginx-tests.yml index 69505a0..0843e1e 100644 --- a/.github/workflows/pr-nginx-tests.yml +++ b/.github/workflows/pr-nginx-tests.yml @@ -34,6 +34,7 @@ jobs: - examples/1.17 - examples/1.16 - examples/custom + - examples/backends steps: - name: Checkout code diff --git a/examples/backends/.lando.yml b/examples/backends/.lando.yml new file mode 100644 index 0000000..34d7b77 --- /dev/null +++ b/examples/backends/.lando.yml @@ -0,0 +1,27 @@ +name: lando-nginx-backends +services: + frontend: + type: nginx:1.29 + webroot: . + backends: + - backend1 + - backend2 + build_as_root: + - apt-get update && apt-get install -y curl + config: + vhosts: config/proxy.conf + backend1: + type: nginx:1.29 + webroot: backend1 + build_as_root: + - apt-get update && apt-get install -y curl + backend2: + type: nginx:1.29 + webroot: backend2 + build_as_root: + - apt-get update && apt-get install -y curl + +# This is important because it lets lando know to test against the plugin in this repo +# DO NOT REMOVE THIS! +plugins: + "@lando/nginx": ../.. diff --git a/examples/backends/README.md b/examples/backends/README.md new file mode 100644 index 0000000..77b3549 --- /dev/null +++ b/examples/backends/README.md @@ -0,0 +1,52 @@ +# NGINX Backends Example + +This example exists primarily to test the following documentation: + +* [nginx Service](https://docs.lando.dev/plugins/nginx) + +## Start up tests + +Run the following commands to get up and running with this example. + +```bash +# Should start up successfully +lando poweroff +lando start +``` + +## Verification commands + +Run the following commands to validate things are rolling as they should. + +```bash +# Should serve frontend content from the app root +lando ssh -s frontend -c "curl -s http://localhost" | grep FRONTEND + +# Should be able to reach backend1 through the frontend proxy +lando ssh -s frontend -c "curl -s http://localhost/backend1/" | grep BACKEND1 + +# Should be able to reach backend2 through the frontend proxy +lando ssh -s frontend -c "curl -s http://localhost/backend2/" | grep BACKEND2 + +# Should have backend1 as a dependency of frontend +lando info -s frontend --format json | grep backend1 + +# Should have backend2 as a dependency of frontend +lando info -s frontend --format json | grep backend2 + +# Should serve backend1 directly on its own port +lando ssh -s backend1 -c "curl -s http://localhost" | grep BACKEND1 + +# Should serve backend2 directly on its own port +lando ssh -s backend2 -c "curl -s http://localhost" | grep BACKEND2 +``` + +## Destroy tests + +Run the following commands to trash this app like nothing ever happened. + +```bash +# Should be destroyed with success +lando destroy -y +lando poweroff +``` diff --git a/examples/backends/backend1/index.html b/examples/backends/backend1/index.html new file mode 100644 index 0000000..e964f4c --- /dev/null +++ b/examples/backends/backend1/index.html @@ -0,0 +1 @@ +BACKEND1 \ No newline at end of file diff --git a/examples/backends/backend2/index.html b/examples/backends/backend2/index.html new file mode 100644 index 0000000..d29dcb9 --- /dev/null +++ b/examples/backends/backend2/index.html @@ -0,0 +1 @@ +BACKEND2 \ No newline at end of file diff --git a/examples/backends/config/proxy.conf b/examples/backends/config/proxy.conf new file mode 100644 index 0000000..239e88f --- /dev/null +++ b/examples/backends/config/proxy.conf @@ -0,0 +1,21 @@ +server { + listen 80; + server_name localhost; + + location /backend1 { + proxy_pass http://backend1:80/; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + } + + location /backend2 { + proxy_pass http://backend2:80/; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + } + + location / { + root "{{LANDO_WEBROOT}}"; + index index.html; + } +} diff --git a/examples/backends/index.html b/examples/backends/index.html new file mode 100644 index 0000000..abeaeff --- /dev/null +++ b/examples/backends/index.html @@ -0,0 +1 @@ +FRONTEND \ No newline at end of file From 06a57263b04b315d2d8e784369025eb1dad22845 Mon Sep 17 00:00:00 2001 From: Aaron Feledy Date: Thu, 19 Feb 2026 19:54:21 -0600 Subject: [PATCH 2/3] feat: implement backends config option Adds a 'backends' array config to the nginx service builder. When specified, it: - Adds depends_on entries ensuring backend services start first - Injects LANDO_NGINX_BACKENDS env var with comma-separated service names - Fully backwards compatible (defaults to empty array) Closes #5 --- builders/nginx.js | 12 ++++++++++++ examples/backends/README.md | 8 +++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/builders/nginx.js b/builders/nginx.js index 21b6a6e..fc921bb 100644 --- a/builders/nginx.js +++ b/builders/nginx.js @@ -62,6 +62,7 @@ module.exports = { }, renderArch: 'amd64', renderTemplate: '1.0.6', + backends: [], ssl: false, webroot: '.', }, @@ -108,6 +109,17 @@ module.exports = { ], }; + // Add depends_on for any configured backends + const backends = _.isArray(options.backends) ? options.backends : []; + if (!_.isEmpty(backends)) { + nginx.depends_on = {}; + backends.forEach(backend => { + nginx.depends_on[backend] = {condition: 'service_started'}; + }); + // Also inject backend names as env var for use in templates + nginx.environment.LANDO_NGINX_BACKENDS = backends.join(','); + } + // Send it downstream super(id, options, {services: _.set({}, options.name, nginx)}); } diff --git a/examples/backends/README.md b/examples/backends/README.md index 77b3549..04ca33b 100644 --- a/examples/backends/README.md +++ b/examples/backends/README.md @@ -28,11 +28,9 @@ lando ssh -s frontend -c "curl -s http://localhost/backend1/" | grep BACKEND1 # Should be able to reach backend2 through the frontend proxy lando ssh -s frontend -c "curl -s http://localhost/backend2/" | grep BACKEND2 -# Should have backend1 as a dependency of frontend -lando info -s frontend --format json | grep backend1 - -# Should have backend2 as a dependency of frontend -lando info -s frontend --format json | grep backend2 +# Should have LANDO_NGINX_BACKENDS env var set on frontend +lando ssh -s frontend -c "env" | grep LANDO_NGINX_BACKENDS | grep backend1 +lando ssh -s frontend -c "env" | grep LANDO_NGINX_BACKENDS | grep backend2 # Should serve backend1 directly on its own port lando ssh -s backend1 -c "curl -s http://localhost" | grep BACKEND1 From ac020753bc7fe4e73b32627b50e330a8eb9443b4 Mon Sep 17 00:00:00 2001 From: Aaron Feledy Date: Thu, 19 Feb 2026 21:57:02 -0600 Subject: [PATCH 3/3] feat: promote npm edge tag to latest when prerelease is promoted Adds a 'released' trigger to the release workflow with a lightweight 'promote' job that runs npm dist-tag to move 'latest' to the current version when a prerelease is promoted to a full release. The existing publish pipeline remains gated to 'published' events only. --- .github/workflows/pr-nginx-tests.yml | 1 - .github/workflows/release.yml | 27 +++++++++++++-- builders/nginx.js | 12 ------- examples/backends/.lando.yml | 27 --------------- examples/backends/README.md | 50 --------------------------- examples/backends/backend1/index.html | 1 - examples/backends/backend2/index.html | 1 - examples/backends/config/proxy.conf | 21 ----------- examples/backends/index.html | 1 - 9 files changed, 25 insertions(+), 116 deletions(-) delete mode 100644 examples/backends/.lando.yml delete mode 100644 examples/backends/README.md delete mode 100644 examples/backends/backend1/index.html delete mode 100644 examples/backends/backend2/index.html delete mode 100644 examples/backends/config/proxy.conf delete mode 100644 examples/backends/index.html diff --git a/.github/workflows/pr-nginx-tests.yml b/.github/workflows/pr-nginx-tests.yml index 0843e1e..69505a0 100644 --- a/.github/workflows/pr-nginx-tests.yml +++ b/.github/workflows/pr-nginx-tests.yml @@ -34,7 +34,6 @@ jobs: - examples/1.17 - examples/1.16 - examples/custom - - examples/backends steps: - name: Checkout code diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9970f11..bfe2b88 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,10 +3,33 @@ name: Publish to NPM on: release: types: - - created - + - published + - released jobs: + # When a prerelease is promoted to a full release, update the npm latest tag + promote: + if: github.event.action == 'released' + runs-on: ubuntu-24.04 + steps: + - name: Checkout code + uses: actions/checkout@v6 + - name: Install node 20 + uses: actions/setup-node@v6 + with: + node-version: '20' + registry-url: https://registry.npmjs.org + - name: Promote edge to latest + run: | + VERSION=$(echo "$TAG_NAME" | sed 's/^v//') + PACKAGE=$(node -p "require('./package.json').name") + npm dist-tag add "$PACKAGE@$VERSION" latest + echo "::notice title=Promoted $VERSION to latest::The latest tag now points to $VERSION (was edge-only)" + env: + TAG_NAME: ${{ github.event.release.tag_name }} + NODE_AUTH_TOKEN: ${{secrets.NPM_DEPLOY_TOKEN}} + deploy: + if: github.event.action == 'published' runs-on: ${{ matrix.os }} env: TERM: xterm diff --git a/builders/nginx.js b/builders/nginx.js index fc921bb..21b6a6e 100644 --- a/builders/nginx.js +++ b/builders/nginx.js @@ -62,7 +62,6 @@ module.exports = { }, renderArch: 'amd64', renderTemplate: '1.0.6', - backends: [], ssl: false, webroot: '.', }, @@ -109,17 +108,6 @@ module.exports = { ], }; - // Add depends_on for any configured backends - const backends = _.isArray(options.backends) ? options.backends : []; - if (!_.isEmpty(backends)) { - nginx.depends_on = {}; - backends.forEach(backend => { - nginx.depends_on[backend] = {condition: 'service_started'}; - }); - // Also inject backend names as env var for use in templates - nginx.environment.LANDO_NGINX_BACKENDS = backends.join(','); - } - // Send it downstream super(id, options, {services: _.set({}, options.name, nginx)}); } diff --git a/examples/backends/.lando.yml b/examples/backends/.lando.yml deleted file mode 100644 index 34d7b77..0000000 --- a/examples/backends/.lando.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: lando-nginx-backends -services: - frontend: - type: nginx:1.29 - webroot: . - backends: - - backend1 - - backend2 - build_as_root: - - apt-get update && apt-get install -y curl - config: - vhosts: config/proxy.conf - backend1: - type: nginx:1.29 - webroot: backend1 - build_as_root: - - apt-get update && apt-get install -y curl - backend2: - type: nginx:1.29 - webroot: backend2 - build_as_root: - - apt-get update && apt-get install -y curl - -# This is important because it lets lando know to test against the plugin in this repo -# DO NOT REMOVE THIS! -plugins: - "@lando/nginx": ../.. diff --git a/examples/backends/README.md b/examples/backends/README.md deleted file mode 100644 index 04ca33b..0000000 --- a/examples/backends/README.md +++ /dev/null @@ -1,50 +0,0 @@ -# NGINX Backends Example - -This example exists primarily to test the following documentation: - -* [nginx Service](https://docs.lando.dev/plugins/nginx) - -## Start up tests - -Run the following commands to get up and running with this example. - -```bash -# Should start up successfully -lando poweroff -lando start -``` - -## Verification commands - -Run the following commands to validate things are rolling as they should. - -```bash -# Should serve frontend content from the app root -lando ssh -s frontend -c "curl -s http://localhost" | grep FRONTEND - -# Should be able to reach backend1 through the frontend proxy -lando ssh -s frontend -c "curl -s http://localhost/backend1/" | grep BACKEND1 - -# Should be able to reach backend2 through the frontend proxy -lando ssh -s frontend -c "curl -s http://localhost/backend2/" | grep BACKEND2 - -# Should have LANDO_NGINX_BACKENDS env var set on frontend -lando ssh -s frontend -c "env" | grep LANDO_NGINX_BACKENDS | grep backend1 -lando ssh -s frontend -c "env" | grep LANDO_NGINX_BACKENDS | grep backend2 - -# Should serve backend1 directly on its own port -lando ssh -s backend1 -c "curl -s http://localhost" | grep BACKEND1 - -# Should serve backend2 directly on its own port -lando ssh -s backend2 -c "curl -s http://localhost" | grep BACKEND2 -``` - -## Destroy tests - -Run the following commands to trash this app like nothing ever happened. - -```bash -# Should be destroyed with success -lando destroy -y -lando poweroff -``` diff --git a/examples/backends/backend1/index.html b/examples/backends/backend1/index.html deleted file mode 100644 index e964f4c..0000000 --- a/examples/backends/backend1/index.html +++ /dev/null @@ -1 +0,0 @@ -BACKEND1 \ No newline at end of file diff --git a/examples/backends/backend2/index.html b/examples/backends/backend2/index.html deleted file mode 100644 index d29dcb9..0000000 --- a/examples/backends/backend2/index.html +++ /dev/null @@ -1 +0,0 @@ -BACKEND2 \ No newline at end of file diff --git a/examples/backends/config/proxy.conf b/examples/backends/config/proxy.conf deleted file mode 100644 index 239e88f..0000000 --- a/examples/backends/config/proxy.conf +++ /dev/null @@ -1,21 +0,0 @@ -server { - listen 80; - server_name localhost; - - location /backend1 { - proxy_pass http://backend1:80/; - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - } - - location /backend2 { - proxy_pass http://backend2:80/; - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - } - - location / { - root "{{LANDO_WEBROOT}}"; - index index.html; - } -} diff --git a/examples/backends/index.html b/examples/backends/index.html deleted file mode 100644 index abeaeff..0000000 --- a/examples/backends/index.html +++ /dev/null @@ -1 +0,0 @@ -FRONTEND \ No newline at end of file