Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tests] migrate tests to Github Actions #47

Merged
merged 2 commits into from
Jan 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "airbnb-base",
"env": {
"node": true
"node": true,
},
"rules": {
"strict": 0,
Expand All @@ -13,5 +13,6 @@
"exports": "always-multiline",
"functions": "ignore",
}],
}
"prefer-object-spread": "off",
},
}
7 changes: 7 additions & 0 deletions .github/workflows/node-pretest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: 'Tests: pretest/posttest'

on: [pull_request, push]

jobs:
tests:
uses: ljharb/actions/.github/workflows/pretest.yml@main
105 changes: 105 additions & 0 deletions .github/workflows/node.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
name: 'Tests: node.js'

on: [pull_request, push]

jobs:
matrix:
runs-on: ubuntu-latest
outputs:
latest: ${{ steps.set-matrix.outputs.requireds }}
minors: ${{ steps.set-matrix.outputs.optionals }}
steps:
- uses: ljharb/actions/node/matrix@main
id: set-matrix
with:
versionsAsRoot: true
type: majors
preset: '>=4' # mocha 5 requires node 4

latest:
needs: [matrix]
name: 'latest majors'
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
node-version: ${{ fromJson(needs.matrix.outputs.latest) }}
eslint:
- 7
- 6
- 5
- 4
- 4.14 # last version without messageId
- 3
exclude:
- node-version: 5
- node-version: 4
- node-version: 15
eslint: 8
- node-version: 13
eslint: 8
- node-version: 11
eslint: 8
- node-version: 11
eslint: 7
- node-version: 10
eslint: 8
- node-version: 9
eslint: 8
- node-version: 9
eslint: 7
- node-version: 8
eslint: 8
- node-version: 8
eslint: 7
- node-version: 7
eslint: 8
- node-version: 7
eslint: 7
- node-version: 7
eslint: 6
- node-version: 6
eslint: 8
- node-version: 6
eslint: 7
- node-version: 6
eslint: 6
- node-version: 5
eslint: 8
- node-version: 5
eslint: 7
- node-version: 5
eslint: 6
- node-version: 5
eslint: 5
- node-version: 4
eslint: 8
- node-version: 4
eslint: 7
- node-version: 4
eslint: 6
- node-version: 4
eslint: 5

steps:
- uses: actions/checkout@v2
- uses: ljharb/actions/node/install@main
name: 'nvm install ${{ matrix.node-version }} && npm install'
with:
node-version: ${{ matrix.node-version }}
after_install: npm install --no-save "eslint@${{ matrix.eslint }}"
skip-ls-check: ${{ matrix.node-version < 10 && true || false }}
env:
NPM_CONFIG_LEGACY_PEER_DEPS: true
- run: npx ls-engines
if: ${{ matrix.node-version >= 12 }}
- run: npm run tests-only
- uses: codecov/codecov-action@v1

node:
name: 'node.js'
needs: [latest]
runs-on: ubuntu-latest
steps:
- run: 'echo tests completed'
15 changes: 15 additions & 0 deletions .github/workflows/rebase.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Automatic Rebase

on: [pull_request_target]

jobs:
_:
name: "Automatic Rebase"

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: ljharb/rebase@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
12 changes: 12 additions & 0 deletions .github/workflows/require-allow-edits.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Require “Allow Edits”

on: [pull_request_target]

jobs:
_:
name: "Require “Allow Edits”"

runs-on: ubuntu-latest

steps:
- uses: ljharb/require-allow-edits@main
26 changes: 0 additions & 26 deletions .travis.yml

This file was deleted.

12 changes: 10 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@
"lint": "eslint .",
"mocha": "mocha --recursive",
"postversion": "git commit package.json CHANGELOG.md -m \"Version $npm_package_version\" && npm run tag && git push && git push --tags && npm publish",
"prepublish": "in-publish && safe-publish-latest || not-in-publish",
"prepublishOnly": "safe-publish-latest",
"prepublish": "not-in-publish || safe-publish-latest",
"pretest": "npm run --silent lint",
"preversion": "npm run test && npm run check-changelog && npm run check-only-changelog-changed",
"tag": "git tag v$npm_package_version",
"test": "npm run tests-only",
"tests-only": "npm run mocha --silent tests",
"posttest": "aud --production",
"version:major": "npm --no-git-tag-version version major",
"version:minor": "npm --no-git-tag-version version minor",
"version:patch": "npm --no-git-tag-version version patch"
Expand All @@ -44,15 +46,21 @@
"eslint": "^2.0.0 || ^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0"
},
"devDependencies": {
"aud": "^2.0.0",
"chai": "^4.2.0",
"eslint": "^2.0.0 || ^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0",
"eslint-config-airbnb-base": "^14.0.0",
"eslint-plugin-import": "^2.18.2",
"in-publish": "^2.0.0",
"ls-engines": "^0.6.4",
"mocha": "^5.2.0",
"safe-publish-latest": "^1.1.3"
"safe-publish-latest": "^1.1.3",
"semver": "^6.3.0"
},
"dependencies": {
"has": "^1.0.3"
},
"engines": {
"node": ">= 4"
}
}
17 changes: 9 additions & 8 deletions tests/lib/rules/no-unused-styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
'use strict';

const RuleTester = require('eslint').RuleTester;
const semver = require('semver');
const eslintVersion = require('eslint/package.json').version;

const rule = require('../../../lib/rules/no-unused-styles');

const parserOptions = {
ecmaVersion: 2019,
ecmaVersion: 6,
ecmaFeatures: {
jsx: true,
},
Expand All @@ -19,8 +21,7 @@ const parserOptions = {

const ruleTester = new RuleTester();
ruleTester.run('no-unused-styles', rule, {

valid: [
valid: [].concat(
{
parserOptions,
code: `
Expand Down Expand Up @@ -411,8 +412,8 @@ ruleTester.run('no-unused-styles', rule, {
`.trim(),
},

{ // TODO handle object spread better?
parserOptions,
semver.satisfies('>= 5', eslintVersion) ? { // TODO handle object spread better?
parserOptions: Object.assign({}, parserOptions, { ecmaVersion: 2019 }),
code: `
import { css } from 'withStyles';

Expand All @@ -426,7 +427,7 @@ ruleTester.run('no-unused-styles', rule, {
...foo,
}))(Foo);
`.trim(),
},
} : [],

{
parserOptions,
Expand Down Expand Up @@ -498,8 +499,8 @@ ruleTester.run('no-unused-styles', rule, {
foo: {},
}))(Foo);
`.trim(),
},
],
}
),

invalid: [
{
Expand Down