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

feat(ci): Divide lint/docs and add linear-history and no-fixups #2737

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all 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
121 changes: 104 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ on:

jobs:
lint:
name: lint

# begin macro

runs-on: ubuntu-latest
Expand All @@ -28,7 +26,8 @@ jobs:
uses: actions/checkout@v4

# without this, setup-node errors on mismatched yarn versions
- run: corepack enable
- name: Enable corepack
run: corepack enable

- name: Use Node.js
uses: actions/setup-node@v3
Expand All @@ -47,6 +46,35 @@ jobs:
- name: Run yarn lint
run: yarn lint

docs:
# begin macro

runs-on: ubuntu-latest
strategy:
fail-fast: false

steps:
- name: Checkout
uses: actions/checkout@v4

# without this, setup-node errors on mismatched yarn versions
- name: Enable corepack
run: corepack enable

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

- name: Install dependencies
run: yarn install --immutable

# end macro

- name: Run yarn build
run: yarn build

# build the API docs to verify it works
- name: build API docs
run: yarn docs
Expand All @@ -56,8 +84,6 @@ jobs:
run: yarn docs:markdown-for-agoric-documentation-repo

test:
name: test

# begin macro

runs-on: ${{ matrix.platform }}
Expand Down Expand Up @@ -98,8 +124,6 @@ jobs:
run: yarn test

test-async-hooks:
name: test-async-hooks

runs-on: ${{ matrix.platform }}
strategy:
fail-fast: false
Expand Down Expand Up @@ -145,8 +169,6 @@ jobs:
run: yarn test

cover:
name: cover

# begin macro

runs-on: ${{ matrix.platform }}
Expand Down Expand Up @@ -181,8 +203,6 @@ jobs:
run: yarn cover

test262:
name: test262

# begin macro

runs-on: ${{ matrix.platform }}
Expand Down Expand Up @@ -217,8 +237,6 @@ jobs:
run: exit 0 # TODO remove test262 from required tests for CI

test-hermes:
name: test-hermes

# begin macro

runs-on: ${{ matrix.platform }}
Expand Down Expand Up @@ -252,8 +270,6 @@ jobs:
run: yarn test:hermes

viable-release:
name: viable-release

# begin macro

runs-on: ${{ matrix.platform }}
Expand Down Expand Up @@ -296,8 +312,6 @@ jobs:
run: yarn lerna run --reject-cycles --concurrency 1 prepack

test-xs:
name: test-xs

# begin macro

runs-on: ${{ matrix.platform }}
Expand Down Expand Up @@ -384,3 +398,76 @@ jobs:
run: |
PATH=$PATH:$GITHUB_WORKSPACE/bin
yarn test:xs

linear-history:
runs-on: ubuntu-latest
if: >-
github.event_name == 'pull_request' &&
github.event.pull_request.draft == false &&
github.event.pull_request.base.ref == 'master' &&
!contains(github.event.pull_request.labels.*.name, 'bypass:linear-history')
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- shell: bash
env:
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
HEAD_LABEL: ${{ github.event.pull_request.head.label }}
BASE_SHA: ${{ github.event.pull_request.base.sha }}
BASE_LABEL: ${{ github.event.pull_request.base.label }}
run: |
merge_commits=$(git rev-list --merges "$BASE_SHA".."$HEAD_SHA")

if [ -n "$merge_commits" ]; then
echo "Error: merge commits found in $BASE_LABEL..$HEAD_LABEL"

for merge_commit in $merge_commits; do
echo "$merge_commit"
done

exit 1
fi

fixup_commits=
for commit in $(git rev-list $BASE_SHA..$HEAD_SHA); do
case $(git show --pretty=format:%s -s $commit) in fixup\!*|squash\!*|amend\!*)
fixup_commits="$fixup_commits\n$commit"
;;
esac
done

if [ -n "$fixup_commits" ]; then
echo "Error: fixup/squash/amend commits found in $BASE_LABEL..$HEAD_LABEL"
echo -e "$fixup_commits"
exit 1
fi

no-fixup-commits:
runs-on: ubuntu-latest
if: >-
github.event_name == 'pull_request' &&
github.event.pull_request.draft == false &&
github.event.pull_request.base.ref == 'master' &&
!contains(github.event.pull_request.labels.*.name, 'bypass:linear-history')

env:
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
BASE_SHA: ${{ github.event.pull_request.base.sha }}

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check for fixup commits
id: fixup-commits
run: |
if ! git merge-base --is-ancestor "$BASE_SHA" "$HEAD_SHA"; then
echo "PR is not up to date with target branch, skipping fixup commit check"
elif [[ $(git rev-list "$BASE_SHA".."$HEAD_SHA" --grep="^\(fixup\|amend\|squash\)! " | wc -l) -eq 0 ]]; then
echo "No fixup/amend/squash commits found in commit history"
else
echo "fixup/amend/squash commits found in commit history"
exit 1
fi
Loading