From 6787839bf523b546aadac391d162c966c5dfb295 Mon Sep 17 00:00:00 2001 From: Ben Holloway Date: Mon, 17 Jan 2022 10:19:07 +1100 Subject: [PATCH] github actions for CI --- .github/workflows/ci.yaml | 37 +++++++++++++++++++ .../package.json | 2 +- test/index.js | 7 ++-- 3 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/ci.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..034ba8c --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,37 @@ +name: ci +on: + - push +jobs: + test: + runs-on: ${{ matrix.os }} + continue-on-error: true + strategy: + matrix: + os: + - ubuntu-latest + - macos-latest + - windows-latest + node: + - '12.x' + - '14.x' + - 'lts/*' + band: + - 'webpack4' + - 'webpack5' + steps: + - name: Use OS ${{ matrix.os }} + uses: actions/checkout@v2 + - name: Use Node@${{ matrix.node }} + uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node }} + cache: 'yarn' + - name: Install Dependencies + run: yarn install + - name: Unit test + run: yarn test:unit + - name: End-to-End test ${{ matrix.band }} + if: ${{ !(matrix.node == 'lts/*' && matrix.band == 'webpack4') }} + run: yarn test:e2e + env: + ONLY: '${{ matrix.band }}*' diff --git a/packages/resolve-url-loader/test/webpack4-sassloader8-nodesass4/package.json b/packages/resolve-url-loader/test/webpack4-sassloader8-nodesass4/package.json index d843286..5b1c44d 100644 --- a/packages/resolve-url-loader/test/webpack4-sassloader8-nodesass4/package.json +++ b/packages/resolve-url-loader/test/webpack4-sassloader8-nodesass4/package.json @@ -2,7 +2,7 @@ "name": "webpack4-sassloader8-nodesass4", "version": "1.0.0", "engines": { - "node": ">=12.0.0" + "node": ">=12.0.0 <16.0.0" }, "dependencies": { "css-loader": "^5.2.4", diff --git a/test/index.js b/test/index.js index 1ab367b..93535ac 100644 --- a/test/index.js +++ b/test/index.js @@ -2,7 +2,7 @@ const {dirname, normalize, join} = require('path'); const {readdirSync} = require('fs'); -const {platform: os} = require('process'); +const {platform: os, version} = require('process'); const compose = require('compose-function'); const sequence = require('promise-compose'); const micromatch = require('micromatch'); @@ -16,6 +16,7 @@ const {testBase} = require('./cases/common/test'); // tests are located in resolve-url-loader package which might differ from package under test const PLATFORMS_DIR = compose(normalize, join)(__dirname, '..', 'packages', 'resolve-url-loader', 'test'); const CASES_DIR = join(__dirname, 'cases'); +const VERSION_MAJOR = version.match(/\d+/).shift(); const testIncluded = process.env.ONLY ? (arr) => { @@ -69,7 +70,7 @@ filterTests() platform, sequence( init({ - directory: [process.cwd(), join('tmp', '.cache'), platform], + directory: [process.cwd(), join('tmp', '.cache'), `node${VERSION_MAJOR}-${platform}`], ttl: false, debug: (process.env.DEBUG === 'true'), env: { @@ -131,7 +132,7 @@ filterTests() RESOLVE_URL_LOADER_TEST_HARNESS: 'stderr' }), meta({ - cacheDir: join(process.cwd(), 'tmp', '.cache', platform), + cacheDir: join(process.cwd(), join('tmp', '.cache'), `node${VERSION_MAJOR}-${platform}`), version: getVersionHash(platform) }), ...filterTests(platform).map(caseName => require(join(CASES_DIR, caseName)))