-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from piotr-oles/feature/initial-implementation
feat: initial implementation
- Loading branch information
Showing
7 changed files
with
5,932 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
name: CI/CD | ||
on: [push] | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v1 | ||
|
||
- name: Setup node | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: 10 | ||
|
||
- name: Yarn cache directory | ||
id: yarn-cache | ||
run: echo "::set-output name=dir::$(yarn cache dir)" | ||
|
||
- name: Yarn cache | ||
uses: actions/cache@v2 | ||
with: | ||
path: ${{ steps.yarn-cache.outputs.dir }} | ||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-yarn- | ||
- name: Install dependencies | ||
run: yarn install --frozen-lockfile | ||
|
||
- name: Build | ||
run: yarn build | ||
|
||
- name: Upload build artifact | ||
uses: actions/upload-artifact@v1 | ||
with: | ||
name: lib | ||
path: lib | ||
|
||
release: | ||
runs-on: ubuntu-latest | ||
needs: build | ||
if: "!contains(github.event.head_commit.message, 'ci skip') && !contains(github.event.head_commit.message, 'skip ci')" | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Prepare repository | ||
run: git fetch --unshallow --tags | ||
|
||
- name: Setup node | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: 12 | ||
|
||
- name: Get yarn cache | ||
id: yarn-cache | ||
run: echo "::set-output name=dir::$(yarn cache dir)" | ||
|
||
- uses: actions/cache@v1 | ||
with: | ||
path: ${{ steps.yarn-cache.outputs.dir }} | ||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-yarn- | ||
- name: Install dependencies | ||
run: yarn install --frozen-lockfile | ||
|
||
- name: Download build artifact | ||
uses: actions/download-artifact@v1 | ||
with: | ||
name: lib | ||
path: lib | ||
|
||
- name: Release | ||
env: | ||
GH_TOKEN: ${{ secrets.GH_TOKEN }} | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
run: yarn release | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,61 @@ | ||
# karton | ||
Create sandbox for package e2e tests | ||
<div align="center"> | ||
|
||
<h1>karton </h1> | ||
<p>Create sandbox for E2E tests 📦</p> | ||
|
||
</div> | ||
|
||
## Installation | ||
|
||
This loader requires minimum Node.js 10 | ||
|
||
```sh | ||
# with npm | ||
npm install --save-dev karton | ||
|
||
# with yarn | ||
yarn add --dev karton | ||
``` | ||
|
||
## Usage | ||
|
||
This package helps you with writing E2E tests for your packages. | ||
Example: | ||
|
||
```typescript | ||
import { createSandbox, Sandbox } from "karton"; | ||
import path from 'path'; | ||
import fs from 'fs-extra'; | ||
|
||
describe('my-package', () => { | ||
let sandbox: Sandbox; | ||
beforeEach(async () => { | ||
sandbox = await createSandbox(); | ||
}); | ||
afterEach(async () => { | ||
await sandbox.destroy(); | ||
}); | ||
|
||
it.each([ | ||
'^4.0.0', | ||
'^5.0.0' | ||
])('works with webpack %p', async (webpackVersion) => { | ||
const packageJSON = JSON.parse( | ||
await fs.readFile('fixtures/package.json', 'utf-8') | ||
); | ||
packageJSON.dependencies['webpack'] = webpackVersion; | ||
packageJSON.dependencies['my-package'] = path.resolve(__dirname, '../my-package-0.0.0.tgz'); | ||
|
||
await sandbox.write('package.json', JSON.stringify(packageJSON)); | ||
await sandbox.write('src/test.js', await fs.readFile('fixtures/src/test.js')); | ||
|
||
await sandbox.exec('yarn install'); | ||
const result = await sandbox.exec('node src/test.js'); | ||
|
||
expect(result).toEqual('my-package awesome output'); | ||
}); | ||
}) | ||
``` | ||
|
||
## License | ||
MIT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
{ | ||
"name": "karton", | ||
"version": "0.0.0", | ||
"description": "Create sandbox for package e2e tests", | ||
"main": "lib/index.js", | ||
"types": "lib/index.d.ts", | ||
"repository": "[email protected]:piotr-oles/karton.git", | ||
"author": "Piotr Oleś <[email protected]>", | ||
"license": "MIT", | ||
"scripts": { | ||
"build": "tsc", | ||
"format": "prettier src --write", | ||
"release": "auto shipit" | ||
}, | ||
"files": [ | ||
"lib/*" | ||
], | ||
"dependencies": { | ||
"chalk": "^4.1.0", | ||
"cross-spawn": "^7.0.3", | ||
"fs-extra": "^9.1.0", | ||
"strip-ansi": "^6.0.0", | ||
"tree-kill": "^1.2.2" | ||
}, | ||
"devDependencies": { | ||
"@types/cross-spawn": "^6.0.2", | ||
"@types/fs-extra": "^9.0.7", | ||
"auto": "^10.16.5", | ||
"husky": "^4.0.0", | ||
"prettier": "^2.2.1", | ||
"typescript": "^4.1.5" | ||
}, | ||
"auto": { | ||
"plugins": [ | ||
"npm", | ||
"released" | ||
], | ||
"onlyPublishWithReleaseLabel": true, | ||
"shipit": { | ||
"noChangelog": true | ||
} | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "yarn format && yarn build" | ||
} | ||
} | ||
} |
Oops, something went wrong.