Skip to content

Commit

Permalink
Add CI scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
marshallku committed Feb 4, 2024
1 parent 0a46af0 commit 709b6ae
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/scripts/check_type.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

declare -A arr

while IFS= read -r line; do
if [[ $line == apps/* ]] || [[ $line == packages/* ]]; then
IFS='/' read -ra ADDR <<<"$line"
path="${ADDR[0]}/${ADDR[1]}"
arr[$path]=1
fi
done < <(git diff --name-only --diff-filter=duxb "origin/$BASE" "origin/$HEAD" | grep -E '\.((j|t)sx?)$')

for key in "${!arr[@]}"; do
package_file="$key/package.json"

if [[ ! -f "$package_file" ]]; then
continue
fi

if grep -q '"build": ' "$package_file"; then
package_name=$(grep -oP '"name"\s*:\s*"\K[^"]*' "$package_file")

pnpm run build --filter="$package_name" || exit 1
fi

if grep -q '"test": ' "$package_file"; then
package_name=$(grep -oP '"name"\s*:\s*"\K[^"]*' "$package_file")

pnpm run test --filter="$package_name" || exit 1
fi
done
4 changes: 4 additions & 0 deletions .github/scripts/check_working_tree.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

git_status=$([[ -n $(git status --porcelain) ]] && echo "true" || echo "false")
echo "$git_status"
13 changes: 13 additions & 0 deletions .github/scripts/commit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

if [[ -z $(git status --porcelain) ]]; then
exit 0
fi

files_to_commit=${FILES:-"-A"}

git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
git add "$files_to_commit"
git commit -m "$MESSAGE"
git push
24 changes: 24 additions & 0 deletions .github/workflows/ci_push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: CI / Push

on:
- push

env:
CI: true

jobs:
check-spelling:
name: Check spelling
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: marshallku/actions/check-spelling@master
send-notification:
needs: [check-spelling]
if: ${{ failure() }}
uses: marshallku/actions/.github/workflows/send-notification.yml@master
with:
failed: ${{ contains(join(needs.*.result, ','), 'failure') }}
message: "CI job failed - push"
secrets:
url: ${{ secrets.DISCORD_WEBHOOK_URI }}
36 changes: 36 additions & 0 deletions .github/workflows/ci_push_master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: CI / Push

on:
push:
branches:
- master

env:
CI: true

jobs:
lint-all:
name: Check quality with ESLint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: marshallku/actions/setup-pnpm@master
- name: Check code quality
run: pnpm lint
build-all:
name: Build all packages and apps
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: marshallku/actions/setup-pnpm@master
- name: Build apps and packages
run: pnpm build
send-notification:
needs: [lint-all, build-all]
if: ${{ failure() }}
uses: marshallku/actions/.github/workflows/send-notification.yml@master
with:
failed: ${{ contains(join(needs.*.result, ','), 'failure') }}
message: "CI job failed - push on master"
secrets:
url: ${{ secrets.DISCORD_WEBHOOK_URI }}

0 comments on commit 709b6ae

Please sign in to comment.