Feat/sync 20241204 #24
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test Package | |
on: pull_request | |
jobs: | |
build-and-test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
# with: | |
# token: ${{ secrets.GIT_TOKEN }} | |
# fetch-depth: 0 | |
- name: Enable node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 20 | |
- name: Install dependencies | |
run: yarn | |
- name: Setup Python for Deps | |
run: sudo apt-get update && sudo apt-get install python3-dev -y | |
- name: Determine changed packages using Changesets | |
id: changes | |
run: | | |
set -e # Ensure the script exits on error | |
changed_packages=$(npx -y changeset status --since origin/develop | grep '@xdefi-tech/' | cut -d'/' -f2 | sort -u | tr '\n' ',') | |
changed_packages=${changed_packages%,} # Remove trailing comma | |
if [ -z "$changed_packages" ]; then | |
echo "No changesets found. Testing all packages." | |
echo "changed_packages=all" >> $GITHUB_ENV | |
else | |
echo "changed_packages=$changed_packages" >> $GITHUB_ENV | |
fi | |
- name: Build | |
if: env.changed_packages != '' | |
run: yarn build --concurrency 2 | |
- name: Run tests for changed packages | |
run: | | |
if [ "${{ env.changed_packages }}" = "all" ]; then | |
yarn test --concurrency 2 | |
else | |
for package in $(echo ${{ env.changed_packages }} | tr ',' '\n'); do | |
echo "Running tests for package: @xdefi-tech/$package" | |
yarn workspace @xdefi-tech/$package test | |
done | |
fi | |
- name: Upload coverage reports to Codecov | |
if: env.changed_packages != '' | |
uses: codecov/[email protected] | |
env: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
slug: XDeFi-tech/chains |