Skip to content

Commit

Permalink
Merge branch 'main' into cg/addCreateSitesFromTemplateFeature
Browse files Browse the repository at this point in the history
  • Loading branch information
charliegerard committed Feb 3, 2022
2 parents e0994ff + d5d421d commit 00f1991
Show file tree
Hide file tree
Showing 127 changed files with 3,302 additions and 2,350 deletions.
68 changes: 57 additions & 11 deletions .github/workflows/main.yml
Expand Up @@ -8,19 +8,55 @@ on:

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
node-version: ['*']
steps:
# Sets an output parameter if this is a release PR
- name: Check for release
id: release-check
run: echo "::set-output name=IS_RELEASE::true"
if: "${{ startsWith(github.head_ref, 'release-') }}"
- name: Git checkout
uses: actions/checkout@v2
if: '${{!steps.release-check.outputs.IS_RELEASE}}'
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache-dependency-path: 'npm-shrinkwrap.json'
check-latest: true
if: '${{!steps.release-check.outputs.IS_RELEASE}}'
- name: Install core dependencies
run: npm ci --no-audit
if: '${{!steps.release-check.outputs.IS_RELEASE}}'
- name: Install site dependencies
run: npm run site:build:install
if: '${{!steps.release-check.outputs.IS_RELEASE}}'
- name: Linting
run: npm run format:ci
if: '${{!steps.release-check.outputs.IS_RELEASE}}'
- name: Run unit tests
run: npm run test:ci:ava:unit
if: '${{!steps.release-check.outputs.IS_RELEASE}}'
test:
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
node-version: [12.x, '*']
machine: ['0', '1', '2', '3', '4', '5', '6']

exclude:
- os: macOS-latest
node-version: '12.x'
- os: windows-latest
node-version: '12.x'
fail-fast: false

steps:
# Sets an output parameter if this is a release PR
- name: Check for release
Expand All @@ -32,36 +68,35 @@ jobs:
run: |
REG ADD HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\TCPIP\Parameters /v MaxUserPort /t REG_DWORD /d 32768 /f
REG ADD HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\TCPIP\Parameters /v TcpTimedWaitDelay /t REG_DWORD /d 30 /f
if: "${{ matrix.os == 'windows-latest' }}"
if: "${{ matrix.os == 'windows-latest' && !steps.release-check.outputs.IS_RELEASE }}"
- name: Git checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
if: '${{!steps.release-check.outputs.IS_RELEASE}}'
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache-dependency-path: 'npm-shrinkwrap.json'
check-latest: true
if: '${{!steps.release-check.outputs.IS_RELEASE}}'
- name: Install core dependencies
run: npm ci --no-audit
- name: Install site dependencies
run: npm run site:build:install
- name: Linting
run: npm run format:ci
if: "${{ matrix.node-version == '*' && !steps.release-check.outputs.IS_RELEASE}}"
if: '${{!steps.release-check.outputs.IS_RELEASE}}'
- name: Determine Test Command
uses: haya14busa/action-cond@v1
id: testCommand
with:
cond: ${{ github.event_name == 'pull_request' }}
if_true: 'npm run test:affected ${{ github.event.pull_request.base.sha }}' # on pull requests test with the project graph only the affected tests
if_false: 'npm run test:ci' # on the base branch run all the tests as security measure
if_false: 'npm run test:ci:ava:integration' # on the base branch run all the tests as security measure
if: '${{ !steps.release-check.outputs.IS_RELEASE }}'
- name: Prepare tests
run: npm run test:init
- name: Tests
if: '${{ !steps.release-check.outputs.IS_RELEASE }}'
- name: Tests
run: ${{ steps.testCommand.outputs.value }}
env:
# GitHub secrets are not available when running on PR from forks
Expand All @@ -74,18 +109,29 @@ jobs:
# Changes the polling interval used by the file watcher
CHOKIDAR_INTERVAL: 20
CHOKIDAR_USEPOLLING: 1
- name: Get test coverage flags

# split tests across multiple machines
CI_NODE_INDEX: ${{ matrix.machine }}
CI_NODE_TOTAL: 7
if: '${{ !steps.release-check.outputs.IS_RELEASE }}'
- name: Get test coverage flags
id: test-coverage-flags
run: |-
os=${{ matrix.os }}
node=${{ matrix.node-version }}
echo "::set-output name=os::${os/-latest/}"
echo "::set-output name=node::node_${node//[.*]/}"
shell: bash
- uses: codecov/codecov-action@v2
if: '${{ !steps.release-check.outputs.IS_RELEASE }}'
- uses: codecov/codecov-action@v2
continue-on-error: true
with:
file: coverage/coverage-final.json
flags: ${{ steps.test-coverage-flags.outputs.os }},${{ steps.test-coverage-flags.outputs.node }}
if: '${{ !steps.release-check.outputs.IS_RELEASE }}'
all:
needs: [build, test]
runs-on: ubuntu-latest
steps:
- name: Log success
run: echo "Finished running all tests"
6 changes: 3 additions & 3 deletions .gitignore
Expand Up @@ -28,6 +28,6 @@ site/src/**/*.md

# tests
.eslintcache
tests/hugo-site/resources
tests/hugo-site/out
tests/hugo-site/.hugo_build.lock
tests/integration/hugo-site/resources
tests/integration/hugo-site/out
tests/integration/hugo-site/.hugo_build.lock
30 changes: 30 additions & 0 deletions CHANGELOG.md
Expand Up @@ -7,6 +7,36 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

### [8.15.3](https://github.com/netlify/cli/compare/v8.15.2...v8.15.3) (2022-02-01)


### Bug Fixes

* supply next_run for all scheduled functions calls ([#4163](https://github.com/netlify/cli/issues/4163)) ([1981515](https://github.com/netlify/cli/commit/19815158e0f4ce32bf73990c53fa6bd6dda34e39))

### [8.15.2](https://github.com/netlify/cli/compare/v8.15.1...v8.15.2) (2022-01-31)


### Bug Fixes

* **deps:** update rust crate tokio to 1.16.1 ([#4151](https://github.com/netlify/cli/issues/4151)) ([f1c4d10](https://github.com/netlify/cli/commit/f1c4d1017acba380048c06efa98b51b967f763d2))
* dont show warning message for toml-defined scheduled functions ([#4162](https://github.com/netlify/cli/issues/4162)) ([c89d81a](https://github.com/netlify/cli/commit/c89d81a5d64cdd73e84d7ad8c8cdb9abed990d40))

### [8.15.1](https://github.com/netlify/cli/compare/v8.15.0...v8.15.1) (2022-01-31)


### Bug Fixes

* **deps:** update dependency stripe to v8.201.0 ([#4149](https://github.com/netlify/cli/issues/4149)) ([b2b0faa](https://github.com/netlify/cli/commit/b2b0faa4a66cdc0d6bcbe51ef5ebed1dd8936efd))
* **deps:** update dependency winston to v3.5.0 ([#4150](https://github.com/netlify/cli/issues/4150)) ([a41323f](https://github.com/netlify/cli/commit/a41323f4f8827c228664de9ea38607b4c80efc09))

## [8.15.0](https://github.com/netlify/cli/compare/v8.14.1...v8.15.0) (2022-01-28)


### Features

* add local dev experience for scheduled functions ([#3689](https://github.com/netlify/cli/issues/3689)) ([1c8968d](https://github.com/netlify/cli/commit/1c8968d5ebb50f7fc781b92e37fc3aa3e29f3b33))

### [8.14.1](https://github.com/netlify/cli/compare/v8.14.0...v8.14.1) (2022-01-25)


Expand Down
6 changes: 4 additions & 2 deletions e2e.config.cjs → e2e.config.mjs
@@ -1,5 +1,5 @@
module.exports = {
files: ['e2e/**/*.e2e.js'],
const config = {
files: ['e2e/**/*.e2e.mjs'],
cache: true,
// eslint-disable-next-line no-magic-numbers
concurrency: 5,
Expand All @@ -8,3 +8,5 @@ module.exports = {
tap: false,
timeout: '5m',
}

export default config
23 changes: 12 additions & 11 deletions e2e/install.e2e.js → e2e/install.e2e.mjs
@@ -1,22 +1,23 @@
const { mkdir } = require('fs').promises
const { existsSync } = require('fs')
const { platform } = require('os')
const { join, resolve } = require('path')
const process = require('process')
import { promises, readFileSync, existsSync } from 'fs'
import { platform } from 'os'
import { join, resolve } from 'path'
import { env } from 'process'
import { fileURLToPath } from 'url'

const test = require('ava')
const execa = require('execa')
import test from 'ava'
import execa from 'execa'

const { version } = require('../package.json')
import { packageManagerConfig, packageManagerExists } from './utils.mjs'

const { packageManagerConfig, packageManagerExists } = require('./utils')
const { version } = JSON.parse(readFileSync(fileURLToPath(new URL('../package.json', import.meta.url)), 'utf-8'))
const { mkdir } = promises

/**
* Prepares the workspace for the test suite to run
* @param {string} folderName
*/
const prepare = async (folderName) => {
const folder = join(process.env.E2E_TEST_WORKSPACE, folderName)
const folder = join(env.E2E_TEST_WORKSPACE, folderName)
await mkdir(folder, { recursive: true })
return folder
}
Expand All @@ -27,7 +28,7 @@ Object.entries(packageManagerConfig).forEach(([packageManager, { install: instal

testSuite(`${packageManager} → should install the cli and run the help command`, async (t) => {
const cwd = await prepare(`${packageManager}-try-install`)
await execa(...installCmd, { stdio: process.env.DEBUG ? 'inherit' : 'ignore', cwd })
await execa(...installCmd, { stdio: env.DEBUG ? 'inherit' : 'ignore', cwd })

t.is(existsSync(join(cwd, lockFile)), true, `Generated lock file ${lockFile} does not exists in ${cwd}`)

Expand Down
35 changes: 0 additions & 35 deletions e2e/utils.js

This file was deleted.

35 changes: 35 additions & 0 deletions e2e/utils.mjs
@@ -0,0 +1,35 @@
import { execSync } from 'child_process'
import { readFileSync } from 'fs'
import { env } from 'process'
import { fileURLToPath } from 'url'

const { version } = JSON.parse(readFileSync(fileURLToPath(new URL('../package.json', import.meta.url)), 'utf-8'))

/**
* Checks if a package manager exists
* @param {string} packageManager
* @returns {boolean}
*/
export const packageManagerExists = (packageManager) => {
try {
execSync(`${packageManager} --version`)
return true
} catch {
return false
}
}

export const packageManagerConfig = {
npm: {
install: ['npm', ['install', 'netlify-cli@testing', `--registry=${env.E2E_TEST_REGISTRY}`]],
lockFile: 'package-lock.json',
},
pnpm: {
install: ['pnpm', ['add', `${env.E2E_TEST_REGISTRY}netlify-cli/-/netlify-cli-${version}.tgz`]],
lockFile: 'pnpm-lock.yaml',
},
yarn: {
install: ['yarn', ['add', 'netlify-cli@testing', `--registry=${env.E2E_TEST_REGISTRY}`]],
lockFile: 'yarn.lock',
},
}

0 comments on commit 00f1991

Please sign in to comment.