Skip to content

Commit

Permalink
fix: improve automation
Browse files Browse the repository at this point in the history
  • Loading branch information
stipsan committed Jan 29, 2023
1 parent 346dad7 commit 392109c
Show file tree
Hide file tree
Showing 15 changed files with 27,525 additions and 11,926 deletions.
32 changes: 0 additions & 32 deletions .circleci/config.yml

This file was deleted.

131 changes: 103 additions & 28 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,82 @@
name: CI
name: CI & Release

# Workflow name based on selected inputs. Fallback to default Github naming when expression evaluates to empty string
run-name: >-
${{
inputs.release && 'Publish to NPM' ||
''
}}
on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
inputs:
release:
description: 'Publish new release'
required: true
default: false
type: boolean

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

jobs:
build:
name: Lint and build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions/setup-node@master
- name: Install dependencies
run: npm ci
- uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3
- uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # v3
with:
cache: npm
node-version: lts/*
- run: npm ci
- run: npx ls-engines
- run: npm run prepublishOnly
- name: lint, prettier --check
run: npm run lint
- name: build:lib, test:integration
run: |
npm run build:lib
npm run test:integration
test:
name: Test on node ${{ matrix.node_version }} and ${{ matrix.os }}
runs-on: ${{ matrix.os }}
needs: [build]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
node_version: [12, 14, 16, 17]
# @TODO figure out why windows-latest is hanging so mcuh
#os: [ubuntu-latest, windows-latest, macOS-latest]
os: [ubuntu-latest, macOS-latest]

# Run the testing suite on each major OS with the latest LTS release of Node.js
os: [macos-latest, ubuntu-latest, windows-latest]
node: [lts/*]
# It makes sense to also test the oldest, and latest, versions of Node.js, on ubuntu-only since it's the fastest CI runner
include:
- os: ubuntu-latest
# Test the oldest LTS release of Node that's still receiving bugfixes and security patches, versions older than that have reached End-of-Life
node: lts/-2
- os: ubuntu-latest
# Also test the previous LTS release
node: lts/-1
- os: ubuntu-latest
# Test the actively developed version that will become the latest LTS release next October
node: current
# The `build` job already runs the testing suite in ubuntu and lts/*
exclude:
- os: ubuntu-latest
# Test the oldest LTS release of Node that's still receiving bugfixes and security patches, versions older than that have reached End-of-Life
node: lts/*
steps:
- uses: actions/checkout@master
- name: Use Node.js ${{ matrix.node_version }}
uses: actions/setup-node@master
- uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3
- uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # v3
with:
node-version: ${{ matrix.node_version }}
- name: Install dependencies
run: npm ci
cache: npm
node-version: ${{ matrix.node }}
- run: npm install
- run: npx ls-engines
- name: build:lib, test:integration
run: |
npm run build:lib
Expand All @@ -48,10 +87,12 @@ jobs:
runs-on: ubuntu-latest
needs: [build]
steps:
- uses: actions/checkout@master
- uses: actions/setup-node@master
- name: Install dependencies
run: npm ci
- uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3
- uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # v3
with:
cache: npm
node-version: lts/*
- run: npm ci
- name: build:browser.js, test:browser.js
run: |
npm run build:browser.js
Expand All @@ -72,9 +113,43 @@ jobs:
ports:
- 6379:6379
steps:
- uses: actions/checkout@master
- uses: actions/setup-node@master
- name: Install dependencies
run: npm ci
- uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3
- uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # v3
with:
cache: npm
node-version: lts/*
- run: npm ci
- name: test:e2e
run: npm run test:e2e -- --detectOpenHandles

release:
needs: [build, test, browser, e2e]
# only run if opt-in during workflow_dispatch
if: github.event.inputs.release == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3
with:
# Need to fetch entire commit history to
# analyze every commit since last release
fetch-depth: 0
- uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # v3
with:
node-version: lts/*
cache: npm
- run: npm ci --ignore-scripts
# Branches that will release new versions are defined in .releaserc.json
- run: npx semantic-release
# Don't allow interrupting the release step if the job is cancelled, as it can lead to an inconsistent state
# e.g. git tags were pushed but it exited before `npm publish`
if: always()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
# Re-run semantic release with rich logs if it failed to publish for easier debugging
- run: npx semantic-release --dry-run --debug
if: failure()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

11 changes: 3 additions & 8 deletions .github/workflows/coveralls.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ on:
branches:
- main
pull_request:
branches:
- main

name: Test Coveralls

Expand All @@ -14,17 +12,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Use Node.js 12.x
uses: actions/setup-node@v3
- uses: actions/setup-node@v3
with:
node-version: 12.x

cache: npm
node-version: lts/*
- name: npm install, make test-coverage
run: |
npm ci
npm run coverage
- name: Coveralls
uses: coverallsapp/github-action@master
with:
Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/prettier.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
name: Prettier

on:
push:
branches: [main]

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

jobs:
run:
name: Can the code be prettier? 🤔
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
cache: npm
node-version: lts/*
- run: npm ci --ignore-scripts --only-dev
- uses: actions/cache@v3
with:
path: node_modules/.cache/prettier/.prettier-cache
key: prettier-${{ hashFiles('package-lock.json') }}-${{ hashFiles('.gitignore') }}
- run: npx prettier --ignore-path .gitignore --cache --write .
- run: git restore .github/workflows
- uses: EndBug/add-and-commit@v9
with:
default_author: github_actions
commit: --no-verify
message: 'chore(prettier): 🤖 ✨'
38 changes: 14 additions & 24 deletions .github/workflows/updatecompat.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,26 @@
name: Update compat.md

on:
pull_request:
branches:
- main
push:
branches: [main]

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

jobs:
format:
if: github.repository == 'stipsan/ioredis-mock'
name: Should compat.md be updated? 🤔
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{github.head_ref}}
- name: use node.js 16
uses: actions/setup-node@v3
with:
node-version: 16
- run: npm ci
cache: npm
node-version: lts/*
- run: node scripts/update-compat
- name: commit changes
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add compat.md
git commit -m "docs: update feature compat table"
continue-on-error: true
- name: push changes
uses: ad-m/github-push-action@master
- uses: EndBug/add-and-commit@v9
with:
branch: ${{github.head_ref}}
repository: ${{ github.event.pull_request.head.repo.full_name }}
github_token: ${{ secrets.GITHUB_TOKEN }}
default_author: github_actions
commit: --no-verify
message: 'docs(compat.md): 🤖 ✨'
4 changes: 4 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "@sanity/semantic-release-preset",
"branches": ["main"]
}
2 changes: 1 addition & 1 deletion data/command-docs.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion data/command-info.json

Large diffs are not rendered by default.

Loading

0 comments on commit 392109c

Please sign in to comment.