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

ci: add workflows and semantic release #86

Merged
merged 20 commits into from
Oct 26, 2021
Merged
Show file tree
Hide file tree
Changes from 16 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
60 changes: 60 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Continuous Integration
on: push

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Setup | Checkout
uses: actions/checkout@v1

- uses: actions/cache@v2
with:
path: "**/node_modules"
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}

- name: Setup | Install dependencies
run: yarn install --frozen-lockfile

- name: Lint | Eslint
run: yarn run lint

build:
name: Build
runs-on: ubuntu-18.04
timeout-minutes: 10
steps:
- name: Setup | Checkout
uses: actions/checkout@v1

- uses: actions/cache@v2
with:
path: "**/node_modules"
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}

- name: Setup | Install dependencies
run: yarn install --frozen-lockfile

- name: Build
run: yarn run build

commitlint:
name: Commit lint
runs-on: ubuntu-18.04
timeout-minutes: 10
steps:
- name: Setup | Checkout
uses: actions/checkout@v1

- uses: actions/cache@v2
with:
path: "**/node_modules"
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}

- name: Setup | Install dependencies
run: yarn install --frozen-lockfile

- name: Commitlint
run: git log -1 --pretty=format:"%s" | yarn commitlint
88 changes: 88 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Release

on:
push:
branches:
- feat/semantic-release # TODO - change the branch

jobs:
bundler:
runs-on: ubuntu-latest

steps:
- name: Setup | Clone codesandbox-client
uses: actions/checkout@v2
with:
repository: codesandbox/codesandbox-client

- uses: actions/cache@v2
with:
path: "**/node_modules"
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}

- name: Setup | Node.js
uses: actions/setup-node@v2
with:
node-version: "10.23.2"
registry-url: "https://npm.pkg.github.com/"

- name: Setup | Install dependencies
run: yarn

- name: Prepare | Build dependencies
run: yarn build:deps

- name: Prepare | Build sandpack bundler
run: yarn build:sandpack

- name: Archive bundler artifacts
uses: actions/upload-artifact@v2
with:
name: bundler
path: www/**/*.*

publish:
runs-on: ubuntu-latest
needs: [bundler]
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

steps:
- name: Setup | Checkout
uses: actions/checkout@v2
with:
# pulls all commits (needed for lerna / semantic release to correctly version)
fetch-depth: "0"

- name: Setup | Node.js
uses: actions/setup-node@v2
with:
node-version: "12.22.4"
danilowoz marked this conversation as resolved.
Show resolved Hide resolved
registry-url: "https://npm.pkg.github.com/"

- name: Setup | Configure git user
run: |
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor }}@users.noreply.github.com"

- uses: actions/cache@v2
with:
path: "**/node_modules"
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}

- name: Setup | Install dependencies
run: yarn install --frozen-lockfile

- name: Prepare | Download artifacts
uses: actions/download-artifact@v2
with:
name: bundler
path: bundler

- name: Prepare | Build
run: yarn run build:publish

- name: Release | Lerna Publish
run: lerna publish --canary prerelease --yes #TODO - remove canary
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn commitlint --edit "$1"
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
yarn run lint-staged
6 changes: 6 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
extends: [
"@commitlint/config-lerna-scopes",
"@commitlint/config-conventional",
],
};
19 changes: 19 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"packages": [
"sandpack-client",
"sandpack-react"
],
"npmClient": "yarn",
"version": "independent",
danilowoz marked this conversation as resolved.
Show resolved Hide resolved
"useWorkspaces": true,
"command": {
"version": {
"conventionalCommits": true,
"message": "chore: [skip ci] bump packages"
},
"publish": {
"conventionalCommits": true,
"message": "chore: [skip ci] bump packages"
}
}
}
12 changes: 9 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
"private": true,
"workspaces": [
"sandpack-client",
"sandpack-react",
"sandpack-playground"
danilowoz marked this conversation as resolved.
Show resolved Hide resolved
"sandpack-react"
],
"description": "",
"scripts": {
"lint": "eslint '**/*.ts?(x)' --fix",
"format": "prettier --write '**/*.ts?(x)'",
"build": "yarn workspaces run build",
"build:publish": "yarn workspaces run build:publish",
danilowoz marked this conversation as resolved.
Show resolved Hide resolved
"prepare": "husky install"
},
"repository": {
Expand All @@ -21,9 +21,13 @@
"author": "CodeSandbox",
"license": "GPL-2.0",
"devDependencies": {
"@commitlint/cli": "^13.1.0",
"@commitlint/config-conventional": "^13.1.0",
"@commitlint/config-lerna-scopes": "^13.1.0",
"@typescript-eslint/eslint-plugin": "^4.0.0",
"@typescript-eslint/parser": "^4.0.0",
"babel-eslint": "^10.0.0",
"commitlint": "^13.1.0",
"eslint": "^7.5.0",
"eslint-config-prettier": "^8.1.0",
"eslint-config-react-app": "^6.0.0",
Expand All @@ -32,7 +36,9 @@
"eslint-plugin-jsx-a11y": "^6.3.1",
"eslint-plugin-react": "^7.20.3",
"eslint-plugin-react-hooks": "^4.0.8",
"husky": "^5.2.0",
"husky": "^7.0.1",
"lerna": "^4.0.0",
"lerna-changelog": "^2.1.0",
"lint-staged": "^10.5.4",
"prettier": "^2.2.1"
}
Expand Down
25 changes: 16 additions & 9 deletions sandpack-client/gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const del = require("del");
const gulp = require("gulp");
const removeSourcemaps = require("gulp-remove-sourcemaps");

gulp.task("copy-sandbox", () =>
const dist = "./sandpack/";
const paths = process.env.CI
danilowoz marked this conversation as resolved.
Show resolved Hide resolved
? ["../../bundler/www/**/!(*.map)", "!../../bundler/www/public/**"]
: [
"../../codesandbox-client/www/**/!(*.map)",
"!../../codesandbox-client/www/public/**",
];

const remove = () => del(dist);
const copyFolder = () =>
gulp
.src([
"../../codesandbox-client/www/**/*.*",
"!../../codesandbox-client/www/**/*.map",
"!../../codesandbox-client/www/stats.json",
"!../../codesandbox-client/www/public/**/*.*",
])
.src(paths, { matchBase: true })
.pipe(removeSourcemaps())
.pipe(gulp.dest("./sandpack/"))
);
.pipe(gulp.dest(dist));

exports["default"] = gulp.series(remove, copyFolder);
8 changes: 5 additions & 3 deletions sandpack-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"build:cjs": "tsc -p tsconfig.cjs.json",
"build:esm": "tsc -p tsconfig.esm.json",
"lint": "tslint -t codeFrame 'src/**/*.ts' 'test/**/*.ts'",
"build:publish": "yarn build && rimraf sandpack && gulp copy-sandbox",
"build:publish": "yarn build && gulp",
"build:bundler": "gulp",
"start": "tsc -p tsconfig.esm.json --watch"
},
"files": [
Expand All @@ -39,8 +40,9 @@
"babel-loader": "^7.1.5",
"core-js": "^3.7.0",
"cross-env": "^5.0.1",
"gulp": "^3.9.1",
"gulp-remove-sourcemaps": "1.0.1",
"del": "^6.0.0",
"gulp": "^4.0.2",
"gulp-remove-sourcemaps": "^1.0.1",
"regenerator-runtime": "^0.13.7",
"rimraf": "^2.6.2",
"ts-node": "^4.1.0",
Expand Down
9 changes: 0 additions & 9 deletions sandpack-playground/README.md

This file was deleted.

34 changes: 0 additions & 34 deletions sandpack-playground/package.json

This file was deleted.

30 changes: 0 additions & 30 deletions sandpack-playground/src/App.tsx

This file was deleted.

33 changes: 0 additions & 33 deletions sandpack-playground/src/index.html

This file was deleted.

Loading