Skip to content

Commit

Permalink
build: Setup Initial CI (#11)
Browse files Browse the repository at this point in the history
Setup initial CI pipeline for testing, linting, and type checking.
  • Loading branch information
nicholas-codecov authored Nov 28, 2023
1 parent 35c629a commit 573b692
Show file tree
Hide file tree
Showing 14 changed files with 1,166 additions and 603 deletions.
15 changes: 15 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
name: Bug report
about: Create a report to help us improve
title: ""
labels: ""
assignees: ""
---

<!--
Sentry/Codecov employees and contractors can delete or ignore the following.
-->

# 📣 Feedback / 🐛 Bugs

Do you want to file a bug report and/or feature request for Codecov? [Please use our feedback repo instead](https://github.com/codecov/feedback/issues).
15 changes: 15 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
name: Feature request
about: Suggest an idea for this project
title: ""
labels: ""
assignees: ""
---

<!--
Sentry/Codecov employees and contractors can delete or ignore the following.
-->

# 📣 Feedback / 🐛 Bugs

Do you want to file a bug report and/or feature request for Codecov? [Please use our feedback repo instead](https://github.com/codecov/feedback/issues).
13 changes: 13 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Description

# Code Example

# Notable Changes

<!--
Sentry/Codecov employees and contractors can delete or ignore the following.
-->

# Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. In 2022 this entity acquired Codecov and as result Sentry is going to need some rights from me in order to utilize my contributions in this PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.
33 changes: 33 additions & 0 deletions .github/workflows/cache_cleanup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: cleanup caches by a branch
on:
pull_request:
types:
- closed

jobs:
cleanup:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4

- name: Cleanup
run: |
gh extension install actions/gh-actions-cache
REPO=${{ github.repository }}
BRANCH="refs/pull/${{ github.event.pull_request.number }}/merge"
echo "Fetching list of cache key"
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH -L 100 | cut -f 1 )
## Setting this to not fail the workflow while deleting cache keys.
set +e
echo "Deleting caches..."
for cacheKey in $cacheKeysForPR
do
gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm
done
echo "Done"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
209 changes: 209 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
name: CI

on:
push:
branches:
- main
- staging
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
install:
name: Install deps
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 18

- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8
run_install: false

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Cache node_modules
id: cache-node-modules
uses: actions/cache@v3
env:
cache-name: cache-codecov-js-bundle-plugin-node-modules
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-${{ env.cache-name }}-
- name: Install dependencies
run: pnpm install

lint:
name: Run Lint
runs-on: ubuntu-latest
needs: install
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 18

- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8
run_install: false

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Cache node_modules
id: cache-node-modules
uses: actions/cache@v3
env:
cache-name: cache-codecov-js-bundle-plugin-node-modules
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-${{ env.cache-name }}-
- name: Install dependencies
run: pnpm install

- name: Build packages
run: pnpm run build

- name: Run linter
run: pnpm run lint

type-check:
name: Run Type Checker
runs-on: ubuntu-latest
needs: install
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 18

- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8
run_install: false

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Cache node_modules
id: cache-node-modules
uses: actions/cache@v3
env:
cache-name: cache-codecov-js-bundle-plugin-node-modules
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-${{ env.cache-name }}-
- name: Install dependencies
run: pnpm install

- name: Build packages
run: pnpm run build

- name: Run TSC
run: pnpm run type-check

unit-test:
name: Run Unit Tests
runs-on: ubuntu-latest
needs: install
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 18

- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8
run_install: false

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Cache node_modules
id: cache-node-modules
uses: actions/cache@v3
env:
cache-name: cache-codecov-js-bundle-plugin-node-modules
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-${{ env.cache-name }}-
- name: Install dependencies
run: pnpm install

- name: Build packages
run: pnpm run build

- name: Run unit tests
run: pnpm run test:unit:ci --maxWorkers=2

# fossa:
# name: Run Fossa
# runs-on: ubuntu-latest
# needs: install
# if: ${{ !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
# steps:
# - name: Checkout
# uses: actions/checkout@v4

# - name: Setup Node
# uses: actions/setup-node@v3
# with:
# node-version: '18.8.0'

# - name: Run Fossa
# uses: fossas/[email protected]
# with:
# api-key: ${{secrets.FOSSA_API_KEY}}
4 changes: 2 additions & 2 deletions bundlers/next-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@
"extends": "../../package.json"
},
"engines": {
"node": ">=20.0.0"
"node": ">=18.0.0"
}
}
}
4 changes: 2 additions & 2 deletions bundlers/rollup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@
"extends": "../../package.json"
},
"engines": {
"node": ">=20.0.0"
"node": ">=18.0.0"
}
}
}
5 changes: 4 additions & 1 deletion bundlers/webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
"@codecov/webpack-plugin": "workspace:^",
"lodash": "^4.17.21"
},
"engines": {
"node": ">=18.0.0"
},
"volta": {
"extends": "../../package.json"
}
}
}
33 changes: 19 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,41 @@
"version": "1.0.0",
"description": "",
"main": "index.js",
"private": true,
"scripts": {
"build": "pnpm -r --filter='./packages/*' run build",
"clean": "pnpm -r --filter='./packages/*' clean && rm -rf node_modules",
"lint": "pnpm -r --filter='./packages/*' lint && manypkg check",
"lint:fix": "pnpm -r --filter='./packages/*' lint:fix && manypkg fix",
"type-check": "pnpm -r --filter='./packages/*' run type-check",
"lint": "pnpm -r --filter='./packages/*' lint",
"lint:fix": "pnpm -r --filter='./packages/*' lint:fix",
"format": "pnpm -r --filter='./packages/*' format && prettier --write '*.{cjs,json}' --ignore-unknown --no-error-on-unmatched-pattern",
"format:check": "pnpm -r --filter='./packages/*' format:check && prettier --check '*.{cjs,json}' --ignore-unknown --no-error-on-unmatched-pattern"
"format:check": "pnpm -r --filter='./packages/*' format:check && prettier --check '*.{cjs,json}' --ignore-unknown --no-error-on-unmatched-pattern",
"test:unit:ci": "pnpm -r --filter='./packages/*' run test:unit:ci"
},
"keywords": [],
"author": "",
"license": "Apache-2.0",
"dependencies": {
"@manypkg/cli": "^0.21.0",
"devDependencies": {
"@total-typescript/ts-reset": "^0.5.1",
"@types/eslint": "^8.44.4",
"@types/node": "^20.8.6",
"@typescript-eslint/eslint-plugin": "^6.8.0",
"@typescript-eslint/parser": "^6.8.0",
"eslint": "^8.51.0",
"@types/eslint": "^8.44.7",
"@types/node": "^20.10.0",
"@typescript-eslint/eslint-plugin": "^6.13.1",
"@typescript-eslint/parser": "^6.13.1",
"eslint": "^8.54.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-isaacscript": "^3.5.6",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-isaacscript": "^3.5.8",
"eslint-plugin-prettier": "^5.0.1",
"prettier": "^3.0.3",
"prettier": "^3.1.0",
"typescript": "^5.3.2"
},
"workspaces": [
"packages/*"
],
"volta": {
"node": "20.9.0"
},
"engines": {
"node": ">=20.0.0"
"node": ">=18.0.0"
}
}
Loading

0 comments on commit 573b692

Please sign in to comment.