From 480f640c98e944c35de7c86a3d3b254d5355bb4c Mon Sep 17 00:00:00 2001 From: ruben-rebelo Date: Tue, 24 Mar 2026 09:42:55 +0000 Subject: [PATCH] chore: Converted CircleCi to Github workflows --- .circleci/comment-artifacts.sh | 22 ----- .circleci/config.yml | 154 -------------------------------- .circleci/deploy-docs.sh | 72 --------------- .github/workflows/workflows.yml | 145 ++++++++++++++++++++++++++++++ 4 files changed, 145 insertions(+), 248 deletions(-) delete mode 100644 .circleci/comment-artifacts.sh delete mode 100644 .circleci/config.yml delete mode 100755 .circleci/deploy-docs.sh create mode 100644 .github/workflows/workflows.yml diff --git a/.circleci/comment-artifacts.sh b/.circleci/comment-artifacts.sh deleted file mode 100644 index 7991e99012..0000000000 --- a/.circleci/comment-artifacts.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -URL="https://callstack-github-bot.herokuapp.com/comment" -LINK="https://output.circle-artifacts.com/output/job/$CIRCLE_WORKFLOW_JOB_ID/artifacts/$CIRCLE_NODE_INDEX/docs/index.html" -TEMPLATE="Hey @{{user.login}}, thank you for your pull request 🤗. The documentation from this branch can be viewed [here]($LINK)." - -read -r -d '' DATA << EOM -{ - "pull_request": "$CIRCLE_PULL_REQUEST", - "template": "$TEMPLATE", - "test": { - "type": "string", - "data": "The documentation from this branch can be viewed" - }, - "update": true -} -EOM - -curl \ - -H "Content-Type: application/json" \ - -d "$DATA" \ - -X POST $URL diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index c4053c5f19..0000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,154 +0,0 @@ -version: 2.1 - -executors: - default: - docker: - - image: cimg/node:20.19.0 - working_directory: ~/react-native-paper - -commands: - attach_project: - steps: - - attach_workspace: - at: ~/react-native-paper - -jobs: - install-dependencies: - executor: default - steps: - - checkout - - attach_project - - restore_cache: - keys: - - dependencies-{{ checksum "package.json" }} - - dependencies- - - restore_cache: - keys: - - dependencies-example-{{ checksum "example/package.json" }} - - dependencies-example- - - run: - name: Install dependencies - command: | - sudo corepack enable - yarn --cwd example --immutable - yarn --cwd docs --immutable - yarn --immutable - - save_cache: - key: dependencies-{{ checksum "package.json" }} - paths: - - node_modules - - save_cache: - key: dependencies-docs-{{ checksum "docs/package.json" }} - paths: - - docs/node_modules - - save_cache: - key: dependencies-example-{{ checksum "example/package.json" }} - paths: - - example/node_modules - - persist_to_workspace: - root: . - paths: - - . - lint: - executor: default - steps: - - attach_project - - run: - name: Lint files - command: | - yarn lint-no-fix - - typescript: - executor: default - steps: - - attach_project - - run: - name: Typecheck files - command: | - yarn typescript - - unit-tests: - executor: default - steps: - - attach_project - - restore_cache: - name: Restore Jest Cache - keys: - - jest-cache-{{ .Branch }} - - jest-cache - - run: - name: Run unit tests - command: | - yarn test --maxWorkers=2 --coverage - - store_artifacts: - path: coverage - destination: coverage - - save_cache: - paths: - - ./cache/jest - key: jest-cache-{{ .Branch }} - - build-package: - executor: default - steps: - - attach_project - - run: - name: Build package - command: | - yarn prepack - node ./scripts/typescript-output-lint - - build-docs: - executor: default - steps: - - attach_project - - run: - name: Build docs - command: | - export DOCUSAURUS_BASE_URL="/output/job/$CIRCLE_WORKFLOW_JOB_ID/artifacts/$CIRCLE_NODE_INDEX/docs/" - cd docs && yarn build && cd .. - bash .circleci/comment-artifacts.sh - - store_artifacts: - path: docs/build - destination: docs - - deploy-docs: - executor: default - steps: - - checkout - - attach_project - - add_ssh_keys: - fingerprints: - - '2f:b4:ed:e1:25:88:5c:4a:03:c2:16:40:56:70:29:29' - - run: - name: Deploy docs to GitHub pages - command: | - bash .circleci/deploy-docs.sh - -workflows: - build-and-test: - jobs: - - install-dependencies - - lint: - requires: - - install-dependencies - - typescript: - requires: - - install-dependencies - - unit-tests: - requires: - - install-dependencies - - build-package: - requires: - - install-dependencies - - build-docs: - requires: - - install-dependencies - filters: - branches: - ignore: main - - deploy-docs: - filters: - branches: - only: - - main diff --git a/.circleci/deploy-docs.sh b/.circleci/deploy-docs.sh deleted file mode 100755 index 5546f8bb2c..0000000000 --- a/.circleci/deploy-docs.sh +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash - -# Based on domenic's tutorial: https://gist.github.com/domenic/ec8b0fc8ab45f39403dd - -set -euxo pipefail # Exit with nonzero exit code if anything fails - -DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" - -SOURCE_BRANCH="main" -TARGET_BRANCH="gh-pages" - -git checkout $SOURCE_BRANCH - -cd $DIR/.. - -# Install React Native Paper dependencies for examples -yarn - -cd docs - -# Save some useful information -REPO=`git config remote.origin.url` -SSH_REPO=${REPO/https:\/\/github.com\//git@github.com:} -SHA=`git rev-parse --verify HEAD` - -# Clone the existing gh-pages for this repo into dist/ -# Create a new empty branch if gh-pages doesn't exist yet (should only happen on first deploy) -git clone $REPO dist -cd dist -git checkout $TARGET_BRANCH || git checkout --orphan $TARGET_BRANCH -cd .. - -# Clean existing dist/ contents -rm -rf dist/**/* || : -rm -f dist/*.{html,css,js,json,map,xml} || : -rmdir dist/* || : - -# Run our build script. -yarn -yarn build - -# Move the built docs to cloned `gh-pages` directory -cp -R build/. dist - -rm -rf build - -# Change directory to the one using `gh-pages` branch -cd dist - -# Configure git. -git config user.name "$COMMIT_AUTHOR_NAME" -git config user.email "$COMMIT_AUTHOR_EMAIL" - -git add -A . - -# If there are no changes to the compiled dist (e.g. this is a README update) then just bail. -if git diff --cached --quiet; then - echo "No changes to the output on this push; exiting." - exit 0 -fi - -# Commit the "changes", i.e. the new version. -# The delta will show diffs between new and old versions. -git commit -m "Deploy to GitHub Pages: ${SHA}" - -# Now that we're all set up, we can push. -git push $SSH_REPO $TARGET_BRANCH - -# Change back to original branch -cd .. -git checkout $SOURCE_BRANCH -yarn diff --git a/.github/workflows/workflows.yml b/.github/workflows/workflows.yml new file mode 100644 index 0000000000..059f14a6cf --- /dev/null +++ b/.github/workflows/workflows.yml @@ -0,0 +1,145 @@ +name: build-and-test + +on: + push: + branches: + - main + pull_request: + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '20.19.0' + cache: 'yarn' + - run: corepack enable + - run: yarn --immutable + - run: yarn lint-no-fix + + typescript: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '20.19.0' + cache: 'yarn' + - run: corepack enable + - run: yarn --immutable + - run: yarn typescript + + unit-tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '20.19.0' + cache: 'yarn' + - run: corepack enable + - run: yarn --immutable + - uses: actions/cache@v4 + with: + path: ./cache/jest + key: jest-cache-${{ github.ref_name }} + restore-keys: jest-cache- + - name: Run unit tests + run: yarn test --maxWorkers=2 --coverage + - uses: actions/upload-artifact@v4 + if: always() + with: + name: coverage + path: coverage + + build-package: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '20.19.0' + cache: 'yarn' + - run: corepack enable + - run: yarn --immutable + - name: Build package + run: | + yarn prepack + node ./scripts/typescript-output-lint + + build-docs: + if: github.ref != 'refs/heads/main' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '20.19.0' + cache: 'yarn' + - run: corepack enable + - run: yarn --immutable + - name: Build docs + run: yarn --cwd docs build + - uses: actions/upload-artifact@v4 + with: + name: docs + path: docs/build + + comment-artifacts: + if: github.event_name == 'pull_request' + needs: build-docs + runs-on: ubuntu-latest + permissions: + pull-requests: write + steps: + - uses: actions/github-script@v7 + with: + script: | + const artifactsUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}/artifacts`; + const body = `Hey @${context.payload.pull_request.user.login}, thank you for your pull request 🤗. The documentation from this branch can be viewed [here](${artifactsUrl}).`; + const marker = 'The documentation from this branch can be viewed'; + + const { data: comments } = await github.rest.issues.listComments({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + }); + + const existing = comments.find(c => c.body.includes(marker)); + + if (existing) { + await github.rest.issues.updateComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: existing.id, + body, + }); + } else { + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + body, + }); + } + + deploy-docs: + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '20.19.0' + cache: 'yarn' + - run: corepack enable + - run: yarn --immutable + - name: Build docs + run: yarn --cwd docs build + - name: Deploy to GitHub Pages + uses: peaceiris/actions-gh-pages@v4 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./docs/build