require a specific node and yarn version (#17205)

Adds a minimum supported node and yarn version to the project. 

Currently if you are on an unsupported version of node or yarn, there is
no messaging telling you that is the issue. The build just fails, and
you are left to figure out it's because of your node version. With this
change, it will be much clearer why any of the node required commands
(e.g. make deps, make generate-dev, make lint-js, make test-js) are not
working, and it will tell you exactly which minimum version of node or
yarn you need.

**After the console error is clear about using an unsupported node
version**


![image](https://github.com/fleetdm/fleet/assets/1153709/4f14bbf0-520e-45bc-911f-071554a996c4)


- [x] Changes file added for user-visible changes in `changes/` or
`orbit/changes/`.
- [x] Manual QA for all new/changed functionality
This commit is contained in:
Gabriel Hernandez 2024-03-13 12:45:28 +00:00 committed by GitHub
parent 1052b6b350
commit 55c7f1e886
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 519 additions and 493 deletions

View File

@ -29,6 +29,12 @@ jobs:
with:
go-version: ${{ vars.GO_VERSION }}
# Set the Node.js version
- name: Set up Node.js ${{ vars.NODE_VERSION }}
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1
with:
node-version: ${{ vars.NODE_VERSION }}
- name: Checkout Code
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
@ -40,7 +46,7 @@ jobs:
**/node_modules
# Use a separate cache for this from other JS jobs since we run the
# webpack steps and will have more to cache.
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/yarn.lock') }}
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/yarn.lock') }}-node_version-${{ vars.NODE_VERSION }}
restore-keys: |
${{ runner.os }}-node_modules-

View File

@ -11,12 +11,12 @@ on:
- patch-*
- prepare-*
paths:
- 'orbit/**.go'
- '.github/workflows/fleet-and-orbit.yml'
- "orbit/**.go"
- ".github/workflows/fleet-and-orbit.yml"
pull_request:
paths:
- 'orbit/**.go'
- '.github/workflows/fleet-and-orbit.yml'
- "orbit/**.go"
- ".github/workflows/fleet-and-orbit.yml"
workflow_dispatch: # Manual
# This allows a subsequently queued workflow run to interrupt previous runs
@ -57,17 +57,22 @@ jobs:
timeout-minutes: 60
strategy:
matrix:
go-version: ['${{ vars.GO_VERSION }}']
mysql: ['mysql:5.7']
go-version: ["${{ vars.GO_VERSION }}"]
mysql: ["mysql:5.7"]
runs-on: ubuntu-latest
needs: gen
steps:
- name: Install Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version: ${{ matrix.go-version }}
# Set the Node.js version
- name: Set up Node.js ${{ vars.NODE_VERSION }}
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1
with:
node-version: ${{ vars.NODE_VERSION }}
- name: Checkout Code
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
@ -162,11 +167,10 @@ jobs:
timeout-minutes: 60
strategy:
matrix:
go-version: ['${{ vars.GO_VERSION }}']
go-version: ["${{ vars.GO_VERSION }}"]
runs-on: ubuntu-latest
needs: gen
steps:
- name: Install Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
@ -196,13 +200,12 @@ jobs:
' > secrets.yml
./build/fleetctl apply -f secrets.yml
# Here we generate the Fleet Desktop and osqueryd targets for
# macOS which can only be generated from a macOS host.
build-macos-targets:
strategy:
matrix:
go-version: ['${{ vars.GO_VERSION }}']
go-version: ["${{ vars.GO_VERSION }}"]
# Set macOS version to '12' (current equivalent to macos-latest) for
# building the binary. This ensures compatibility with macOS version 13 and
# later, avoiding runtime errors on systems using macOS 13 or newer.
@ -211,7 +214,6 @@ jobs:
# or if we revise our minimum supported macOS version.
runs-on: macos-12
steps:
- name: Install Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
@ -233,7 +235,6 @@ jobs:
desktop.app.tar.gz
osqueryd.app.tar.gz
# TODO(lucas): Currently, to simplify the workflow we do all in one job:
# 1. Generate TUF repository (compile Orbit from source).
# 2. Run TUF server on localhost.
@ -250,11 +251,10 @@ jobs:
timeout-minutes: 60
strategy:
matrix:
go-version: ['${{ vars.GO_VERSION }}']
go-version: ["${{ vars.GO_VERSION }}"]
runs-on: ubuntu-latest
needs: [gen, build-macos-targets]
steps:
- name: Install Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
@ -312,13 +312,11 @@ jobs:
path: |
fleet-osquery.msi
orbit-macos:
timeout-minutes: 60
runs-on: macos-latest
needs: [gen, run-tuf-and-gen-pkgs]
steps:
- name: Checkout Code
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
@ -343,8 +341,7 @@ jobs:
done
- name: Run orbit shell
run:
sudo orbit shell -- --json "select * from osquery_info;" | jq -e 'if (.[0]) then true else false end'
run: sudo orbit shell -- --json "select * from osquery_info;" | jq -e 'if (.[0]) then true else false end'
- name: Collect orbit logs
if: always()
@ -364,13 +361,11 @@ jobs:
run: |
./orbit/tools/cleanup/cleanup_macos.sh
orbit-ubuntu:
timeout-minutes: 60
runs-on: ubuntu-latest
needs: [gen, run-tuf-and-gen-pkgs]
steps:
- name: Download deb
id: download
uses: actions/download-artifact@fb598a63ae348fa914e94cd0ff38f362e927b741 # v2
@ -392,8 +387,7 @@ jobs:
done
- name: Run orbit shell
run:
sudo orbit shell -- --json "select * from osquery_info;" | jq -e 'if (.[0]) then true else false end'
run: sudo orbit shell -- --json "select * from osquery_info;" | jq -e 'if (.[0]) then true else false end'
- name: Collect orbit logs
if: always()
@ -413,13 +407,11 @@ jobs:
run: |
sudo apt remove fleet-osquery -y
orbit-windows:
timeout-minutes: 60
needs: [gen, run-tuf-and-gen-pkgs]
runs-on: windows-latest
steps:
- name: Download msi
id: download
uses: actions/download-artifact@fb598a63ae348fa914e94cd0ff38f362e927b741 # v2

View File

@ -3,7 +3,7 @@ name: goreleaser
on:
push:
tags:
- 'fleet-*'
- "fleet-*"
# This allows a subsequently queued workflow run to interrupt previous runs
concurrency:
@ -41,6 +41,12 @@ jobs:
with:
go-version: ${{ vars.GO_VERSION }}
# Set the Node.js version
- name: Set up Node.js ${{ vars.NODE_VERSION }}
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1
with:
node-version: ${{ vars.NODE_VERSION }}
- name: Install JS Dependencies
run: make deps-js

View File

@ -3,18 +3,18 @@ name: Docker publish
on:
push:
branches:
- 'main'
- 'prepare-*'
- 'patch-*'
- "main"
- "prepare-*"
- "patch-*"
paths-ignore:
- 'handbook/**'
- 'website/**'
- 'mdm-profiles/**'
- "handbook/**"
- "website/**"
- "mdm-profiles/**"
pull_request:
paths-ignore:
- 'handbook/**'
- 'website/**'
- 'mdm-profiles/**'
- "handbook/**"
- "website/**"
- "mdm-profiles/**"
workflow_dispatch: # Manual
# This allows a subsequently queued workflow run to interrupt previous runs
@ -54,6 +54,12 @@ jobs:
with:
go-version: ${{ vars.GO_VERSION }}
# Set the Node.js version
- name: Set up Node.js ${{ vars.NODE_VERSION }}
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1
with:
node-version: ${{ vars.NODE_VERSION }}
- name: Install Dependencies
run: make deps

View File

@ -3,12 +3,12 @@ name: Test Fleet website
on:
pull_request:
paths:
- 'website/**'
- 'docs/**'
- 'handbook/**'
- 'schema/**'
- 'articles/**'
- '.github/workflows/test-website.yml'
- "website/**"
- "docs/**"
- "handbook/**"
- "schema/**"
- "articles/**"
- ".github/workflows/test-website.yml"
# This allows a subsequently queued workflow run to interrupt previous runs
concurrency:
@ -40,7 +40,6 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
# Download top-level dependencies and build Storybook in the website's assets/ folder.
- run: npm install --legacy-peer-deps && npm run build-storybook -- -o ./website/assets/storybook --loglevel verbose

View File

@ -36,6 +36,12 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
# Set the Node.js version
- name: Set up Node.js ${{ vars.NODE_VERSION }}
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1
with:
node-version: ${{ vars.NODE_VERSION }}
- name: Checkout Code
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
@ -69,6 +75,12 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
# Set the Node.js version
- name: Set up Node.js ${{ vars.NODE_VERSION }}
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1
with:
node-version: ${{ vars.NODE_VERSION }}
- name: Checkout Code
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3

View File

@ -144,7 +144,7 @@ analyze-go:
go test -tags full,fts5,netgo -race -cover ./...
test-js:
npm test
yarn test
test: lint test-go test-js

1
changes/min-node-version Normal file
View File

@ -0,0 +1 @@
- add a minimum supported node version in the package.json

View File

@ -2,6 +2,10 @@
"name": "@fleetdm/fleet",
"version": "0.99.99",
"description": "The premier osquery fleet manager.",
"engines": {
"node": "20.11.1",
"yarn": ">=1.22.21"
},
"private": true,
"scripts": {
"lint": "eslint frontend --ext .js,.jsx,.ts,.tsx",