From f3a7127297350c08d33c6b5bddac1ccd5d186ba1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Fri, 6 Oct 2023 18:04:28 +0300 Subject: [PATCH 001/137] chore: remove all actions and add new action for commenting diffs --- .github/workflows/build-templates.yml | 261 -------------------------- .github/workflows/check-project.yml | 27 --- .github/workflows/comment-diffs.yml | 64 +++++++ .github/workflows/deploy-docs.yml | 43 ----- .github/workflows/rebase.yml | 28 --- 5 files changed, 64 insertions(+), 359 deletions(-) delete mode 100644 .github/workflows/build-templates.yml delete mode 100644 .github/workflows/check-project.yml create mode 100644 .github/workflows/comment-diffs.yml delete mode 100644 .github/workflows/deploy-docs.yml delete mode 100644 .github/workflows/rebase.yml diff --git a/.github/workflows/build-templates.yml b/.github/workflows/build-templates.yml deleted file mode 100644 index c5a1de290..000000000 --- a/.github/workflows/build-templates.yml +++ /dev/null @@ -1,261 +0,0 @@ -name: Build template -on: - workflow_dispatch: - push: - branches: - - main - paths: - - '.github/workflows/build-templates.yml' - - 'packages/create-react-native-library/**' - - '!**.md' - pull_request: - branches: - - main - -jobs: - build: - env: - TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} - TURBO_TEAM: ${{ secrets.TURBO_TEAM }} - - strategy: - fail-fast: false - matrix: - os: - - ubuntu - - macos - type: - - module-legacy - - module-mixed - - module-new - - view-legacy - - view-mixed - - view-new - language: - - java-objc - - java-swift - - kotlin-objc - - kotlin-swift - exclude: - - os: macos - language: kotlin-objc - - os: macos - language: kotlin-swift - - type: module-new - language: java-swift - - type: module-new - language: kotlin-swift - - type: module-mixed - language: java-swift - - type: module-mixed - language: kotlin-swift - - type: view-new - language: java-swift - - type: view-new - language: kotlin-swift - - type: view-mixed - language: java-swift - - type: view-mixed - language: kotlin-swift - include: - - os: ubuntu - type: library - language: js - - os: ubuntu - type: module-legacy - language: cpp - - os: ubuntu - type: module-mixed - language: cpp - - os: ubuntu - type: module-new - language: cpp - - os: macos - type: module-legacy - language: cpp - - os: macos - type: module-mixed - language: cpp - - os: macos - type: module-new - language: cpp - - concurrency: - group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.os }}-${{ matrix.type }}-${{ matrix.language }} - cancel-in-progress: true - - runs-on: ${{ matrix.os }}-latest - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Setup - uses: ./.github/actions/setup - - - name: Build package - run: | - yarn workspace create-react-native-library prepare - - - name: Get working directory - run: | - echo "work_dir=${{ matrix.os }}-${{ matrix.type }}-${{ matrix.language }}" >> $GITHUB_ENV - - - name: Create library - run: | - rm -rf ${{ env.work_dir }} # Workaround for tests failing intermittently - ./packages/create-react-native-library/bin/create-react-native-library ${{ env.work_dir }} \ - --slug @bob/react-native-test \ - --description test \ - --author-name test \ - --author-email test@test \ - --author-url https://test.test \ - --repo-url https://test.test \ - --type ${{ matrix.type }} \ - --languages ${{ matrix.language }} \ - --no-local - - - name: Cache dependencies of library - id: library-yarn-cache - uses: actions/cache@v3 - with: - path: | - ${{ env.work_dir }}/**/node_modules - ${{ env.work_dir }}/**/yarn.lock - key: ${{ runner.os }}-library-yarn-${{ hashFiles(format('{0}/**/package.json', env.work_dir)) }} - restore-keys: | - ${{ runner.os }}-library-yarn- - - - name: Install dependencies of library - if: steps.library-yarn-cache.outputs.cache-hit != 'true' - working-directory: ${{ env.work_dir }} - run: | - touch yarn.lock # Without this Yarn will fail due to the parent directory being a Yarn workspace - rm -f example/yarn.lock # Workaround for cached yarn.lock from older version - yarn install --no-immutable - env: - POD_INSTALL: 0 - - - name: Get build target - working-directory: ${{ env.work_dir }} - run: | - # Build Android for only some matrices to skip redundant builds - if [[ ${{ matrix.os }} == ubuntu ]]; then - if [[ ${{ matrix.type }} == view-* && ${{ matrix.language }} == *-objc ]] || [[ ${{ matrix.type }} == module-* && ${{ matrix.language }} == *-objc ]] || [[ ${{ matrix.type }} == module-* && ${{ matrix.language }} == cpp ]]; then - echo "android_build=1" >> $GITHUB_ENV - fi - fi - - # Build iOS for only some matrices to skip redundant builds - if [[ ${{ matrix.os }} == macos ]]; then - if [[ ${{ matrix.type }} == view-* && ${{ matrix.language }} == java-* ]] || [[ ${{ matrix.type }} == module-* && ${{ matrix.language }} == java-* ]] || [[ ${{ matrix.type }} == module-* && ${{ matrix.language }} == cpp ]]; then - echo "ios_build=1" >> $GITHUB_ENV - fi - fi - - - name: Cache turborepo - if: env.android_build == 1 || env.ios_build == 1 - uses: actions/cache@v3 - with: - path: | - ${{ env.work_dir }}/.turbo - key: ${{ runner.os }}-library-turborepo-${{ matrix.type }}-${{ matrix.language }}-${{ hashFiles(format('{0}/**/yarn.lock', env.work_dir)) }} - restore-keys: | - ${{ runner.os }}-library-turborepo-${{ matrix.type }}-${{ matrix.language }}- - - - name: Check turborepo cache - if: env.android_build == 1 || env.ios_build == 1 - working-directory: ${{ env.work_dir }} - run: | - TURBO_CACHE_STATUS_ANDROID=$(node -p "($(yarn turbo run build:android --cache-dir=".turbo" --dry=json)).tasks.find(t => t.task === 'build:android').cache.status") - TURBO_CACHE_STATUS_IOS=$(node -p "($(yarn turbo run build:ios --cache-dir=".turbo" --dry=json)).tasks.find(t => t.task === 'build:ios').cache.status") - - if [[ $TURBO_CACHE_STATUS_ANDROID == "HIT" ]]; then - echo "turbo_cache_hit_android=1" >> $GITHUB_ENV - fi - - if [[ $TURBO_CACHE_STATUS_IOS == "HIT" ]]; then - echo "turbo_cache_hit_ios=1" >> $GITHUB_ENV - fi - - - name: Lint library - working-directory: ${{ env.work_dir }} - run: | - yarn lint - - - name: Typecheck library - working-directory: ${{ env.work_dir }} - run: | - yarn typecheck - - - name: Test library - working-directory: ${{ env.work_dir }} - run: | - yarn test - - - name: Build library - working-directory: ${{ env.work_dir }} - run: | - yarn prepare - - - name: Build example (Web) - working-directory: ${{ env.work_dir }} - if: matrix.language == 'js' - run: | - yarn example expo export:web - - - name: Install JDK - if: env.android_build == 1 && env.turbo_cache_hit_android != 1 - uses: actions/setup-java@v3 - with: - distribution: 'zulu' - java-version: '11' - - - name: Finalize Android SDK - if: env.android_build == 1 && env.turbo_cache_hit_android != 1 - run: | - /bin/bash -c "yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses > /dev/null" - - - name: Cache Gradle - if: env.android_build == 1 && env.turbo_cache_hit_android != 1 - uses: actions/cache@v3 - with: - path: | - ~/.gradle/wrapper - ~/.gradle/caches - key: ${{ runner.os }}-gradle-${{ hashFiles(format('{0}/example/android/gradle/wrapper/gradle-wrapper.properties', env.work_dir)) }} - restore-keys: | - ${{ runner.os }}-gradle- - - - name: Build example (Android) - if: env.android_build == 1 - working-directory: ${{ env.work_dir }} - run: | - yarn turbo run build:android --cache-dir=".turbo" - - - name: Cache cocoapods - if: env.ios_build == 1 && env.turbo_cache_hit_ios != 1 - id: library-cocoapods-cache - uses: actions/cache@v3 - with: - path: | - ${{ env.work_dir }}/**/ios/Pods - ${{ env.work_dir }}/**/ios/Podfile.lock - key: ${{ runner.os }}-library-cocoapods-${{ hashFiles(format('{0}/example/ios/Podfile', env.work_dir)) }}-${{ hashFiles(format('{0}/**/yarn.lock', env.work_dir)) }} - restore-keys: | - ${{ runner.os }}-library-cocoapods-${{ hashFiles(format('{0}/example/ios/Podfile', env.work_dir)) }}- - ${{ runner.os }}-library-cocoapods- - - - name: Install cocoapods - if: env.ios_build == 1 && env.turbo_cache_hit_ios != 1 && steps.library-cocoapods-cache.outputs.cache-hit != 'true' - working-directory: ${{ env.work_dir }} - run: | - yarn pod-install example/ios - env: - NO_FLIPPER: 1 - - - name: Build example (iOS) - if: env.ios_build == 1 - working-directory: ${{ env.work_dir }} - run: | - yarn turbo run build:ios --cache-dir=".turbo" diff --git a/.github/workflows/check-project.yml b/.github/workflows/check-project.yml deleted file mode 100644 index af539d7c6..000000000 --- a/.github/workflows/check-project.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Check project -on: - push: - branches: - - main - pull_request: - branches: - - main - -jobs: - check-project: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Setup - uses: ./.github/actions/setup - - - name: Lint - run: yarn lint - - - name: Typecheck - run: yarn typecheck - - - name: Build packages - run: yarn lerna run prepare diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml new file mode 100644 index 000000000..cfe7c9e11 --- /dev/null +++ b/.github/workflows/comment-diffs.yml @@ -0,0 +1,64 @@ +name: Comment diffs +on: + workflow_dispatch: + pull_request: + branches: + - main + paths: + - '.github/workflows/build-templates.yml' + - 'packages/create-react-native-library/**' + - '!**.md' + +jobs: + comment-diffs: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup + uses: ./.github/actions/setup + + - name: Build crnl + run: | + yarn workspace create-react-native-library prepare + + - name: Create library + run: | + ./packages/create-react-native-library/bin/create-react-native-library new-version \ + --slug @bob/react-native-test \ + --description test \ + --author-name test \ + --author-email test@test \ + --author-url https://test.test \ + --repo-url https://test.test \ + --type module-mixed \ + --languages java-objc \ + --no-local + + - name: Checkout to main + run: git checkout main + + - name: Setup again + uses: ./.github/actions/setup + + - name: Remove old build and build again + run: | + rm -rf ./packages/create-react-native-library/lib + yarn workspace create-react-native-library prepare + + - name: Create library again + run: | + ./packages/create-react-native-library/bin/create-react-native-library old-version \ + --slug @bob/react-native-test \ + --description test \ + --author-name test \ + --author-email test@test \ + --author-url https://test.test \ + --repo-url https://test.test \ + --type module-mixed \ + --languages java-objc \ + --no-local + + - name: Diff the libraries + run: diff -r old-version new-version diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml deleted file mode 100644 index 69e82b69b..000000000 --- a/.github/workflows/deploy-docs.yml +++ /dev/null @@ -1,43 +0,0 @@ -name: Deploy docs -on: - workflow_dispatch: - push: - branches: - - main - paths: - - '.github/workflows/deploy-docs.yml' - - 'docs/**' - -jobs: - deploy-docs: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Setup - uses: ./.github/actions/setup - - - name: Cache build - uses: actions/cache@v3 - with: - path: | - docs/.next/cache - key: ${{ runner.os }}-nextjs-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('**/package.json') }} - restore-keys: | - ${{ runner.os }}-nextjs-${{ hashFiles('**/yarn.lock') }} - ${{ runner.os }}-nextjs- - - - name: Build docs - run: | - yarn docs build - touch docs/out/.nojekyll - - - name: Deploy to GitHub Pages - uses: JamesIves/github-pages-deploy-action@v4 - with: - branch: gh-pages - folder: docs/out - -permissions: - contents: write diff --git a/.github/workflows/rebase.yml b/.github/workflows/rebase.yml deleted file mode 100644 index af3db7e59..000000000 --- a/.github/workflows/rebase.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: Automatic Rebase -on: - issue_comment: - types: [created] - -jobs: - rebase: - name: Rebase - if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '/rebase') - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Automatic Rebase - uses: cirrus-actions/rebase@1.2 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - # https://github.community/t5/GitHub-Actions/Workflow-is-failing-if-no-job-can-be-ran-due-to-condition/m-p/38186#M3250 - always_job: - name: Always run job - runs-on: ubuntu-latest - steps: - - name: Always run - run: echo "This job is used to prevent the workflow to fail when all other jobs are skipped." From 50578b43a7f8cedf607960f37c7134af91e94e95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Fri, 6 Oct 2023 18:05:50 +0300 Subject: [PATCH 002/137] chore: dummy change --- .../{%- project.package_dir %}/{%- project.name %}Module.java | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/create-react-native-library/templates/java-library-mixed/android/src/main/java/com/{%- project.package_dir %}/{%- project.name %}Module.java b/packages/create-react-native-library/templates/java-library-mixed/android/src/main/java/com/{%- project.package_dir %}/{%- project.name %}Module.java index 6cb6c2d05..01465a217 100644 --- a/packages/create-react-native-library/templates/java-library-mixed/android/src/main/java/com/{%- project.package_dir %}/{%- project.name %}Module.java +++ b/packages/create-react-native-library/templates/java-library-mixed/android/src/main/java/com/{%- project.package_dir %}/{%- project.name %}Module.java @@ -6,6 +6,7 @@ import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactMethod; +// Hi mom! public class <%- project.name -%>Module extends <%- project.name -%>Spec { public static final String NAME = "<%- project.name -%>"; From 4646a40e87a302f39fcf3a029eb302f14a47f94a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Fri, 6 Oct 2023 18:06:05 +0300 Subject: [PATCH 003/137] chore: add diff commenting CI --- .github/workflows/comment-diffs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index cfe7c9e11..5de7d7619 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -5,7 +5,7 @@ on: branches: - main paths: - - '.github/workflows/build-templates.yml' + - '.github/workflows/comment-diffs.yml' - 'packages/create-react-native-library/**' - '!**.md' From 446c7985e36cc258b894435e3f4ceacf8af4e757 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Fri, 6 Oct 2023 18:08:13 +0300 Subject: [PATCH 004/137] chore: use macos runner --- .github/workflows/comment-diffs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 5de7d7619..0d598d3a6 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -11,7 +11,7 @@ on: jobs: comment-diffs: - runs-on: ubuntu-latest + runs-on: macos-latest steps: - name: Checkout uses: actions/checkout@v3 From 81f08de97fd6c84c93f56d1179dae9eba0ef1a9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Fri, 6 Oct 2023 18:12:11 +0300 Subject: [PATCH 005/137] chore: use origin/main --- .github/workflows/comment-diffs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 0d598d3a6..702bf49ac 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -37,7 +37,7 @@ jobs: --no-local - name: Checkout to main - run: git checkout main + run: git checkout origin/main - name: Setup again uses: ./.github/actions/setup From 12a5675a29c0a9ca1d37f16ee46074ec852ef22e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Fri, 6 Oct 2023 18:19:49 +0300 Subject: [PATCH 006/137] chore: add fetch before checkout --- .github/workflows/comment-diffs.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 702bf49ac..c550a6f55 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -37,7 +37,9 @@ jobs: --no-local - name: Checkout to main - run: git checkout origin/main + run: | + git fetch origin main --depth 1 + git checkout origin/main --no-overlay -- docs - name: Setup again uses: ./.github/actions/setup From 727a5ffa8df19795d618d0a56685fea35ffc12eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Fri, 6 Oct 2023 18:33:20 +0300 Subject: [PATCH 007/137] chore: disable setup again for testing --- .github/workflows/comment-diffs.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index c550a6f55..8ebe30244 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -41,8 +41,9 @@ jobs: git fetch origin main --depth 1 git checkout origin/main --no-overlay -- docs - - name: Setup again - uses: ./.github/actions/setup + # Removed this step for the sake of testing + # - name: Setup again # Add a check here to setup again if deps changed + # uses: ./.github/actions/setup - name: Remove old build and build again run: | From e3962a573d2ec796cdd4e61a55089bc0c037a343 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Fri, 6 Oct 2023 18:41:12 +0300 Subject: [PATCH 008/137] chore: comment diff --- .github/workflows/comment-diffs.yml | 38 ++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 8ebe30244..261a2252d 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -64,4 +64,40 @@ jobs: --no-local - name: Diff the libraries - run: diff -r old-version new-version + id: diff + run: | + echo "DIFF_RESULT=$(diff -r old-library new-library)" $GITHUB_OUTPUT + + - name: Comment on PR + uses: actions/github-script@v3 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + const fs = require('fs') + const diff = fs.readFileSync('${{ steps.diff.outputs.DIFF_RESULT }}', 'utf-8'); + + const channel = 'pr-${{ github.event.number }}'; + + const url = `https://expo.dev/@react-navigation/react-navigation-example?serviceType=eas&distribution=expo-go&scheme=exp+react-navigation-example&channel=${channel}&sdkVersion=${sdkVersion}`; + + const body = `The diff + ${diff} + `; + + const comments = await github.issues.listComments({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + }); + + if (comments.data.some(comment => comment.body === body)) { + return; + } + + github.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body + }) + From 59bdf130e71cfb0f85d226866ce34963f940d37b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Fri, 6 Oct 2023 18:45:08 +0300 Subject: [PATCH 009/137] chore: fix string --- .github/workflows/comment-diffs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 261a2252d..aef6bd2a4 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -74,7 +74,7 @@ jobs: github-token: ${{secrets.GITHUB_TOKEN}} script: | const fs = require('fs') - const diff = fs.readFileSync('${{ steps.diff.outputs.DIFF_RESULT }}', 'utf-8'); + const diff = '${{ steps.diff.outputs.DIFF_RESULT }}' const channel = 'pr-${{ github.event.number }}'; From 4aa22eb2c14239a8dff27114608ae85020a35479 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Fri, 6 Oct 2023 18:45:46 +0300 Subject: [PATCH 010/137] chore: remove url from action --- .github/workflows/comment-diffs.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index aef6bd2a4..1686e329a 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -78,8 +78,6 @@ jobs: const channel = 'pr-${{ github.event.number }}'; - const url = `https://expo.dev/@react-navigation/react-navigation-example?serviceType=eas&distribution=expo-go&scheme=exp+react-navigation-example&channel=${channel}&sdkVersion=${sdkVersion}`; - const body = `The diff ${diff} `; From 05d5b98fa7cc5c583aebe697a5847996a620f4f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Fri, 6 Oct 2023 18:55:13 +0300 Subject: [PATCH 011/137] chore: add no example --- .github/workflows/comment-diffs.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 1686e329a..06cf8c9c8 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -34,6 +34,7 @@ jobs: --repo-url https://test.test \ --type module-mixed \ --languages java-objc \ + --no-example \ --no-local - name: Checkout to main @@ -61,11 +62,13 @@ jobs: --repo-url https://test.test \ --type module-mixed \ --languages java-objc \ + --no-example \ --no-local - name: Diff the libraries id: diff run: | + diff -r old-library new-library # Just for debugging, promise I'll delete it echo "DIFF_RESULT=$(diff -r old-library new-library)" $GITHUB_OUTPUT - name: Comment on PR From 1d55b2f9050753291f08d5547e8b03325584559b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Fri, 6 Oct 2023 18:57:49 +0300 Subject: [PATCH 012/137] chore: fix names --- .github/workflows/comment-diffs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 06cf8c9c8..6841f3e30 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -68,7 +68,7 @@ jobs: - name: Diff the libraries id: diff run: | - diff -r old-library new-library # Just for debugging, promise I'll delete it + diff -r old-version new-version # Just for debugging, promise I'll delete it echo "DIFF_RESULT=$(diff -r old-library new-library)" $GITHUB_OUTPUT - name: Comment on PR From d65b37358e0e5cc20b8f33335216be5a6b526ef7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Fri, 6 Oct 2023 19:00:58 +0300 Subject: [PATCH 013/137] chore: add continue on error --- .github/workflows/comment-diffs.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 6841f3e30..31045aa38 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -66,10 +66,11 @@ jobs: --no-local - name: Diff the libraries + continue-on-error: true # Diff will output status -1 if it detects any difference id: diff run: | - diff -r old-version new-version # Just for debugging, promise I'll delete it echo "DIFF_RESULT=$(diff -r old-library new-library)" $GITHUB_OUTPUT + diff -r old-version new-version # Just for debugging, promise I'll delete it - name: Comment on PR uses: actions/github-script@v3 From ced5523c0e75e0ecfe3814242f43f4a1cba6f6d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Fri, 6 Oct 2023 19:08:44 +0300 Subject: [PATCH 014/137] chore: fix diff parms --- .github/workflows/comment-diffs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 31045aa38..5b0ee1ffb 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -69,7 +69,7 @@ jobs: continue-on-error: true # Diff will output status -1 if it detects any difference id: diff run: | - echo "DIFF_RESULT=$(diff -r old-library new-library)" $GITHUB_OUTPUT + echo "DIFF_RESULT=$(diff -r old-version new-version)" $GITHUB_OUTPUT diff -r old-version new-version # Just for debugging, promise I'll delete it - name: Comment on PR From 6d3e11f00d63b09a8d666b1061a975ab902c1554 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Fri, 6 Oct 2023 19:17:08 +0300 Subject: [PATCH 015/137] chore: add || true --- .github/workflows/comment-diffs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 5b0ee1ffb..989f194fb 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -69,8 +69,8 @@ jobs: continue-on-error: true # Diff will output status -1 if it detects any difference id: diff run: | - echo "DIFF_RESULT=$(diff -r old-version new-version)" $GITHUB_OUTPUT - diff -r old-version new-version # Just for debugging, promise I'll delete it + diff -r old-version new-version || true # Just for debugging, promise I'll delete it + echo "DIFF_RESULT=$(diff -r old-version new-version || true)" $GITHUB_OUTPUT - name: Comment on PR uses: actions/github-script@v3 From 42fab43a75f6e66a4a40979a3ee23970690606e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Fri, 6 Oct 2023 19:24:24 +0300 Subject: [PATCH 016/137] chore: print diff --- .github/workflows/comment-diffs.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 989f194fb..d4ec72560 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -66,12 +66,15 @@ jobs: --no-local - name: Diff the libraries - continue-on-error: true # Diff will output status -1 if it detects any difference id: diff run: | diff -r old-version new-version || true # Just for debugging, promise I'll delete it echo "DIFF_RESULT=$(diff -r old-version new-version || true)" $GITHUB_OUTPUT + - name: Print diff + run: | + echo ${{ steps.diff.outputs.DIFF_RESULT }} + - name: Comment on PR uses: actions/github-script@v3 with: From c780129d57e94b2eb995c98e43e1ad332c3685bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Fri, 6 Oct 2023 19:29:29 +0300 Subject: [PATCH 017/137] chore: customize a file for diff --- .../create-react-native-library/templates/common/babel.config.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/create-react-native-library/templates/common/babel.config.js b/packages/create-react-native-library/templates/common/babel.config.js index f842b77fc..718da07e1 100644 --- a/packages/create-react-native-library/templates/common/babel.config.js +++ b/packages/create-react-native-library/templates/common/babel.config.js @@ -1,3 +1,4 @@ module.exports = { + // Hi mom! presets: ['module:metro-react-native-babel-preset'], }; From 48430eaf3a7078a11c39de0a081eabffecc23048 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Fri, 6 Oct 2023 19:36:17 +0300 Subject: [PATCH 018/137] chore: ls --- .github/workflows/comment-diffs.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index d4ec72560..8b4d1d963 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -71,6 +71,11 @@ jobs: diff -r old-version new-version || true # Just for debugging, promise I'll delete it echo "DIFF_RESULT=$(diff -r old-version new-version || true)" $GITHUB_OUTPUT + - name: Ls dirs + run: | + ls -R old-version + ls -R new-version + - name: Print diff run: | echo ${{ steps.diff.outputs.DIFF_RESULT }} From ddd736c06309448e25a4f2791036910cf0a26d40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Fri, 6 Oct 2023 19:42:47 +0300 Subject: [PATCH 019/137] chore: add pipe operator --- .github/workflows/comment-diffs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 8b4d1d963..9f6f8850b 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -69,7 +69,7 @@ jobs: id: diff run: | diff -r old-version new-version || true # Just for debugging, promise I'll delete it - echo "DIFF_RESULT=$(diff -r old-version new-version || true)" $GITHUB_OUTPUT + echo "DIFF_RESULT=$(diff -r old-version new-version || true)" >> $GITHUB_OUTPUT - name: Ls dirs run: | From 861faf6d8eaab84849b76ba39c3061f30bf03f03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Fri, 6 Oct 2023 19:45:49 +0300 Subject: [PATCH 020/137] chore: add no ignore file case --- .github/workflows/comment-diffs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 9f6f8850b..12b4a0a37 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -68,8 +68,8 @@ jobs: - name: Diff the libraries id: diff run: | - diff -r old-version new-version || true # Just for debugging, promise I'll delete it - echo "DIFF_RESULT=$(diff -r old-version new-version || true)" >> $GITHUB_OUTPUT + diff -r --no-ignore-file-name-case old-version new-version || true # Just for debugging, promise I'll delete it + echo "DIFF_RESULT=$(diff -r --no-ignore-file-name-case old-version new-version || true)" >> $GITHUB_OUTPUT - name: Ls dirs run: | From 2f28d653d0349a5df2fa41660a0e9dadc02909ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Fri, 6 Oct 2023 19:51:18 +0300 Subject: [PATCH 021/137] chore: add delimeter --- .github/workflows/comment-diffs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 12b4a0a37..8b550ce0a 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -69,7 +69,7 @@ jobs: id: diff run: | diff -r --no-ignore-file-name-case old-version new-version || true # Just for debugging, promise I'll delete it - echo "DIFF_RESULT=$(diff -r --no-ignore-file-name-case old-version new-version || true)" >> $GITHUB_OUTPUT + echo "DIFF_RESULT={$(diff -r --no-ignore-file-name-case old-version new-version || true)}" >> $GITHUB_OUTPUT - name: Ls dirs run: | From 7142ae2adf65aa760a1abb1ae7829784ded3836a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Fri, 6 Oct 2023 19:55:08 +0300 Subject: [PATCH 022/137] chore: add debug txt --- .github/workflows/comment-diffs.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 8b550ce0a..d9c45c1ee 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -68,11 +68,12 @@ jobs: - name: Diff the libraries id: diff run: | - diff -r --no-ignore-file-name-case old-version new-version || true # Just for debugging, promise I'll delete it - echo "DIFF_RESULT={$(diff -r --no-ignore-file-name-case old-version new-version || true)}" >> $GITHUB_OUTPUT + diff -r --no-ignore-file-name-case old-version new-version >> DEBUG.txt || true # Just for debugging, promise I'll delete it + # echo "DIFF_RESULT={$(diff -r --no-ignore-file-name-case old-version new-version || true)}" >> $GITHUB_OUTPUT - name: Ls dirs run: | + ls DEBUG.txt ls -R old-version ls -R new-version From 0e7c4c043289aae3ab48b39618892b3d59f5e9b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Fri, 6 Oct 2023 20:00:10 +0300 Subject: [PATCH 023/137] chore: divide fetch main and checkout main --- .github/workflows/comment-diffs.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index d9c45c1ee..ad9111aec 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -37,10 +37,11 @@ jobs: --no-example \ --no-local - - name: Checkout to main - run: | - git fetch origin main --depth 1 - git checkout origin/main --no-overlay -- docs + - name: Fetch main + run: git fetch origin main --depth 1 + + - name: Checkout main + run: git checkout origin/main --no-overlay -- docs # Removed this step for the sake of testing # - name: Setup again # Add a check here to setup again if deps changed From 5c5518070c742957d2e86e7e8cf99b189e765939 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Fri, 6 Oct 2023 20:01:23 +0300 Subject: [PATCH 024/137] chore: cat diff --- .github/workflows/comment-diffs.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index ad9111aec..91df7a333 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -74,10 +74,14 @@ jobs: - name: Ls dirs run: | - ls DEBUG.txt + cat DEBUG.txt ls -R old-version ls -R new-version + - name: Cat diff + run: | + cat DEBUG.txt + - name: Print diff run: | echo ${{ steps.diff.outputs.DIFF_RESULT }} From 8cb2442311abe96de3b780b3e4db6f776a4b2c17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Fri, 6 Oct 2023 20:03:19 +0300 Subject: [PATCH 025/137] chore: remove params from git switch --- .github/workflows/comment-diffs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 91df7a333..e4daeb241 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -38,10 +38,10 @@ jobs: --no-local - name: Fetch main - run: git fetch origin main --depth 1 + run: git fetch origin main - name: Checkout main - run: git checkout origin/main --no-overlay -- docs + run: git checkout origin/main # Removed this step for the sake of testing # - name: Setup again # Add a check here to setup again if deps changed From 9233c89852e35486d12d62d77912aa50a64bce11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Fri, 6 Oct 2023 20:06:26 +0300 Subject: [PATCH 026/137] chore: uncomment echo --- .github/workflows/comment-diffs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index e4daeb241..d801dfda6 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -70,7 +70,7 @@ jobs: id: diff run: | diff -r --no-ignore-file-name-case old-version new-version >> DEBUG.txt || true # Just for debugging, promise I'll delete it - # echo "DIFF_RESULT={$(diff -r --no-ignore-file-name-case old-version new-version || true)}" >> $GITHUB_OUTPUT + echo "DIFF_RESULT={$(diff -r --no-ignore-file-name-case old-version new-version || true)}" >> $GITHUB_OUTPUT - name: Ls dirs run: | From 758cbefce22c172c5a88451711c2da45316f67ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Fri, 6 Oct 2023 20:10:22 +0300 Subject: [PATCH 027/137] chore: add delimeter --- .github/workflows/comment-diffs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index d801dfda6..1664ede64 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -70,7 +70,7 @@ jobs: id: diff run: | diff -r --no-ignore-file-name-case old-version new-version >> DEBUG.txt || true # Just for debugging, promise I'll delete it - echo "DIFF_RESULT={$(diff -r --no-ignore-file-name-case old-version new-version || true)}" >> $GITHUB_OUTPUT + echo "DIFF_RESULT=${diff -r --no-ignore-file-name-case old-version new-version || true}" >> $GITHUB_OUTPUT - name: Ls dirs run: | From ab05b40120915a01cd863f7075124aa28ae65246 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Fri, 6 Oct 2023 20:21:27 +0300 Subject: [PATCH 028/137] chore: add EOF --- .github/workflows/comment-diffs.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 1664ede64..f28fd8bd4 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -70,7 +70,10 @@ jobs: id: diff run: | diff -r --no-ignore-file-name-case old-version new-version >> DEBUG.txt || true # Just for debugging, promise I'll delete it - echo "DIFF_RESULT=${diff -r --no-ignore-file-name-case old-version new-version || true}" >> $GITHUB_OUTPUT + echo "DIFF_RESULT<> $GITHUB_ENV + diff -r --no-ignore-file-name-case old-version new-version >> $GITHUB_ENV || true + echo "EOF" >> $GITHUB_ENV + - name: Ls dirs run: | From 5d09f44218f280b27e5c1d41ca62a2e84359e4f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Fri, 6 Oct 2023 20:31:02 +0300 Subject: [PATCH 029/137] chore: use github output --- .github/workflows/comment-diffs.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index f28fd8bd4..7c512fb45 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -70,9 +70,9 @@ jobs: id: diff run: | diff -r --no-ignore-file-name-case old-version new-version >> DEBUG.txt || true # Just for debugging, promise I'll delete it - echo "DIFF_RESULT<> $GITHUB_ENV - diff -r --no-ignore-file-name-case old-version new-version >> $GITHUB_ENV || true - echo "EOF" >> $GITHUB_ENV + echo "DIFF_RESULT<> $GITHUB_OUTPUT + diff -r --no-ignore-file-name-case old-version new-version >> $GITHUB_OUTPUT || true + echo "EOF" >> $GITHUB_OUTPUT - name: Ls dirs From bbc8d71eca351dadac3ac2f47fdd4078b17bf186 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Fri, 6 Oct 2023 20:34:00 +0300 Subject: [PATCH 030/137] chore: use ` --- .github/workflows/comment-diffs.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 7c512fb45..e96436e9e 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -85,17 +85,13 @@ jobs: run: | cat DEBUG.txt - - name: Print diff - run: | - echo ${{ steps.diff.outputs.DIFF_RESULT }} - - name: Comment on PR uses: actions/github-script@v3 with: github-token: ${{secrets.GITHUB_TOKEN}} script: | const fs = require('fs') - const diff = '${{ steps.diff.outputs.DIFF_RESULT }}' + const diff = `${{ steps.diff.outputs.DIFF_RESULT }}` const channel = 'pr-${{ github.event.number }}'; From ca5236e5c40bf12a4b133de7338272c0c4e3eff4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Fri, 6 Oct 2023 20:41:53 +0300 Subject: [PATCH 031/137] chore: improve formatting --- .github/workflows/comment-diffs.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index e96436e9e..7272db5b3 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -91,12 +91,14 @@ jobs: github-token: ${{secrets.GITHUB_TOKEN}} script: | const fs = require('fs') - const diff = `${{ steps.diff.outputs.DIFF_RESULT }}` + const diff = `` const channel = 'pr-${{ github.event.number }}'; const body = `The diff - ${diff} + \`\`\`diff + ${{ steps.diff.outputs.DIFF_RESULT }} + \`\`\` `; const comments = await github.issues.listComments({ From 6427e967cd33a52fb9a231ca9709706362d93896 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Fri, 6 Oct 2023 20:43:21 +0300 Subject: [PATCH 032/137] chore: clean unnecessary parts on script --- .github/workflows/comment-diffs.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 7272db5b3..86a29ad3e 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -90,11 +90,6 @@ jobs: with: github-token: ${{secrets.GITHUB_TOKEN}} script: | - const fs = require('fs') - const diff = `` - - const channel = 'pr-${{ github.event.number }}'; - const body = `The diff \`\`\`diff ${{ steps.diff.outputs.DIFF_RESULT }} From 9bb7c499062008b701f3384a385709890e4bd8e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Fri, 6 Oct 2023 20:56:10 +0300 Subject: [PATCH 033/137] chore: formatting --- .github/workflows/comment-diffs.yml | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 86a29ad3e..1c5b4ddde 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -37,6 +37,10 @@ jobs: --no-example \ --no-local + - name: Store the commit hash + id: head_hash + run: echo "HEAD_HASH=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT + - name: Fetch main run: git fetch origin main @@ -69,31 +73,23 @@ jobs: - name: Diff the libraries id: diff run: | - diff -r --no-ignore-file-name-case old-version new-version >> DEBUG.txt || true # Just for debugging, promise I'll delete it echo "DIFF_RESULT<> $GITHUB_OUTPUT - diff -r --no-ignore-file-name-case old-version new-version >> $GITHUB_OUTPUT || true + # Diff in recursive mod with unified format (unified format uses - and + instead of < and >) + diff -r -u --no-ignore-file-name-case old-version new-version >> $GITHUB_OUTPUT || true echo "EOF" >> $GITHUB_OUTPUT - - - name: Ls dirs - run: | - cat DEBUG.txt - ls -R old-version - ls -R new-version - - - name: Cat diff - run: | - cat DEBUG.txt - - name: Comment on PR uses: actions/github-script@v3 with: github-token: ${{secrets.GITHUB_TOKEN}} script: | - const body = `The diff + const body = `The commit with hash: ${{ steps.head_hash.outputs.HEAD_HASH }} has changed the output of \`create-react-native-library\`. You can find the diff of the change below: + \`\`\`diff ${{ steps.diff.outputs.DIFF_RESULT }} \`\`\` + + > This diff is between this branch and the \`main\` branch. `; const comments = await github.issues.listComments({ From b8ecb19a684986f85d6c13566122bbfe428619c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Fri, 6 Oct 2023 20:57:11 +0300 Subject: [PATCH 034/137] chore: change formatting --- .github/workflows/comment-diffs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 1c5b4ddde..16d6368f3 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -83,13 +83,13 @@ jobs: with: github-token: ${{secrets.GITHUB_TOKEN}} script: | - const body = `The commit with hash: ${{ steps.head_hash.outputs.HEAD_HASH }} has changed the output of \`create-react-native-library\`. You can find the diff of the change below: + const body = `This PR changes the output of \`create-react-native-library\`. You can find the diff of the change below: \`\`\`diff ${{ steps.diff.outputs.DIFF_RESULT }} \`\`\` - > This diff is between this branch and the \`main\` branch. + > This diff is between ${{ steps.head_hash.outputs.HEAD_HASH }} and the \`main\` branch. `; const comments = await github.issues.listComments({ From 708243d57514e392ab53ca7f928d066a8619d02b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Fri, 6 Oct 2023 21:03:59 +0300 Subject: [PATCH 035/137] chore: add commit hash --- .github/workflows/comment-diffs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 16d6368f3..0d60d914f 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -89,7 +89,7 @@ jobs: ${{ steps.diff.outputs.DIFF_RESULT }} \`\`\` - > This diff is between ${{ steps.head_hash.outputs.HEAD_HASH }} and the \`main\` branch. + > This diff is between [${{ steps.head_hash.outputs.HEAD_HASH }}](https://github.com/callstack/react-native-builder-bob/pull/${context.issue.number}/commits/${{ steps.head_hash.outputs.HEAD_HASH }}) and the [main](callstack/react-native-builder-bob/tree/main) branch. `; const comments = await github.issues.listComments({ From 78eda9b85f1a3b592ea4578bd2f85717fa70952c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Fri, 6 Oct 2023 21:13:09 +0300 Subject: [PATCH 036/137] chore: remove hash step --- .github/workflows/comment-diffs.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 0d60d914f..3f2323093 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -37,10 +37,6 @@ jobs: --no-example \ --no-local - - name: Store the commit hash - id: head_hash - run: echo "HEAD_HASH=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT - - name: Fetch main run: git fetch origin main @@ -89,7 +85,7 @@ jobs: ${{ steps.diff.outputs.DIFF_RESULT }} \`\`\` - > This diff is between [${{ steps.head_hash.outputs.HEAD_HASH }}](https://github.com/callstack/react-native-builder-bob/pull/${context.issue.number}/commits/${{ steps.head_hash.outputs.HEAD_HASH }}) and the [main](callstack/react-native-builder-bob/tree/main) branch. + > This diff is between [${ context.sha }](https://github.com/callstack/react-native-builder-bob/pull/${context.issue.number}/commits/${ context.sha }) and the [main](https://github.com/callstack/react-native-builder-bob/tree/main) branch. `; const comments = await github.issues.listComments({ From 43551e4dd22f8ff39850fd0f0a202788cdafd83a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Fri, 6 Oct 2023 21:19:53 +0300 Subject: [PATCH 037/137] chore: remove diff hashes --- .github/workflows/comment-diffs.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 3f2323093..5132f3214 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -74,6 +74,8 @@ jobs: diff -r -u --no-ignore-file-name-case old-version new-version >> $GITHUB_OUTPUT || true echo "EOF" >> $GITHUB_OUTPUT + # TODO: Upload the files with diff + - name: Comment on PR uses: actions/github-script@v3 with: @@ -83,10 +85,7 @@ jobs: \`\`\`diff ${{ steps.diff.outputs.DIFF_RESULT }} - \`\`\` - - > This diff is between [${ context.sha }](https://github.com/callstack/react-native-builder-bob/pull/${context.issue.number}/commits/${ context.sha }) and the [main](https://github.com/callstack/react-native-builder-bob/tree/main) branch. - `; + \`\`\``; const comments = await github.issues.listComments({ issue_number: context.issue.number, From 0c5ba94b564f97ea5b34e30e096c6bd8d3c04775 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Fri, 6 Oct 2023 21:46:29 +0300 Subject: [PATCH 038/137] chore: remove timestamps --- .github/workflows/comment-diffs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 5132f3214..cb91b3187 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -71,7 +71,7 @@ jobs: run: | echo "DIFF_RESULT<> $GITHUB_OUTPUT # Diff in recursive mod with unified format (unified format uses - and + instead of < and >) - diff -r -u --no-ignore-file-name-case old-version new-version >> $GITHUB_OUTPUT || true + diff -r -u --no-ignore-file-name-case old-version new-version | sed -re 's/(---|\+\+\+) (.+)\t.+/\1 \2/' >> $GITHUB_OUTPUT || true echo "EOF" >> $GITHUB_OUTPUT # TODO: Upload the files with diff From 6bc1ee88f61c6189c445070f44c6acb3a80c389a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 7 Oct 2023 08:21:18 +0300 Subject: [PATCH 039/137] chore: commit --- .github/workflows/comment-diffs.yml | 39 ----------------------------- 1 file changed, 39 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index cb91b3187..35b50dc38 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -65,42 +65,3 @@ jobs: --languages java-objc \ --no-example \ --no-local - - - name: Diff the libraries - id: diff - run: | - echo "DIFF_RESULT<> $GITHUB_OUTPUT - # Diff in recursive mod with unified format (unified format uses - and + instead of < and >) - diff -r -u --no-ignore-file-name-case old-version new-version | sed -re 's/(---|\+\+\+) (.+)\t.+/\1 \2/' >> $GITHUB_OUTPUT || true - echo "EOF" >> $GITHUB_OUTPUT - - # TODO: Upload the files with diff - - - name: Comment on PR - uses: actions/github-script@v3 - with: - github-token: ${{secrets.GITHUB_TOKEN}} - script: | - const body = `This PR changes the output of \`create-react-native-library\`. You can find the diff of the change below: - - \`\`\`diff - ${{ steps.diff.outputs.DIFF_RESULT }} - \`\`\``; - - const comments = await github.issues.listComments({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - }); - - if (comments.data.some(comment => comment.body === body)) { - return; - } - - github.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body - }) - From 4fc336484d5bca00cc72e07e1665b0dadea99151 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 7 Oct 2023 08:46:40 +0300 Subject: [PATCH 040/137] chore: commit to diffview branch --- .github/workflows/comment-diffs.yml | 92 ++++++++++++++++++++++------- 1 file changed, 70 insertions(+), 22 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 35b50dc38..1301ac0d8 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -37,31 +37,79 @@ jobs: --no-example \ --no-local - - name: Fetch main - run: git fetch origin main + - name: Create the Differ repo + run: | + mkdir differ + cd differ + git init + git remote add origin $DIFF_VIEW_SSH + desired_branch="new-version" + # Check if the branch exists on the remote repository + if git ls-remote --heads origin "$desired_branch" | grep -q "$desired_branch"; then + echo "The branch $desired_branch already exists on the remote repository." + git fetch origin "$desired_branch" # Fetch the branch from the remote + git checkout "$desired_branch" # Switch to the existing branch + else + echo "The branch $desired_branch does not exist on the remote repository." + git checkout -b "$desired_branch" # Create a new branch and switch to it + fi - - name: Checkout main - run: git checkout origin/main + - name: Clean the Differ repo + run: | + cd differ + # Remove everything except the .git folder and it's contents. + for i in `ls | grep -v ".git"` ; do rm -rf $i; done; - # Removed this step for the sake of testing - # - name: Setup again # Add a check here to setup again if deps changed - # uses: ./.github/actions/setup + - name: Delete .git of new-version + run: | + rm -rf new-version/.git - - name: Remove old build and build again + - name: Copy everything inside new-version to differ run: | - rm -rf ./packages/create-react-native-library/lib - yarn workspace create-react-native-library prepare + cp new-version/* differ - - name: Create library again + - name: Commit everything in differ run: | - ./packages/create-react-native-library/bin/create-react-native-library old-version \ - --slug @bob/react-native-test \ - --description test \ - --author-name test \ - --author-email test@test \ - --author-url https://test.test \ - --repo-url https://test.test \ - --type module-mixed \ - --languages java-objc \ - --no-example \ - --no-local + cd differ + git add -A && git commit -m "Automatic commit" + + - name: Pushes to another repository + uses: cpina/github-action-push-to-another-repository@main + env: + SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY }} + API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }} + with: + source-directory: 'output' + destination-github-username: $DIFF_VIEW_USERNAME + destination-repository-name: $DIFF_VIEW_REPO_NAME + user-email: test@test.com + target-branch: new-version + + # - name: Fetch main + # run: git fetch origin main + # + # - name: Checkout main + # run: git checkout origin/main + # + # # Removed this step for the sake of testing + # # - name: Setup again # Add a check here to setup again if deps changed + # # uses: ./.github/actions/setup + # + # - name: Remove old build and build again + # run: | + # rm -rf ./packages/create-react-native-library/lib + # yarn workspace create-react-native-library prepare + # + # - name: Create library again + # run: | + # ./packages/create-react-native-library/bin/create-react-native-library old-version \ + # --slug @bob/react-native-test \ + # --description test \ + # --author-name test \ + # --author-email test@test \ + # --author-url https://test.test \ + # --repo-url https://test.test \ + # --type module-mixed \ + # --languages java-objc \ + # --no-example \ + # --no-local From af0c05fd1a37700def1cc54fe69e27a1e612dc82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 7 Oct 2023 08:51:07 +0300 Subject: [PATCH 041/137] chore: use ubuntu latest --- .github/workflows/comment-diffs.yml | 48 +++++++++++++++++------------ 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 1301ac0d8..c82585499 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -11,31 +11,39 @@ on: jobs: comment-diffs: - runs-on: macos-latest + runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v3 - - name: Setup - uses: ./.github/actions/setup - - - name: Build crnl - run: | - yarn workspace create-react-native-library prepare - - - name: Create library + # - name: Setup + # uses: ./.github/actions/setup + # + # - name: Build crnl + # run: | + # yarn workspace create-react-native-library prepare + # + # - name: Create library + # run: | + # ./packages/create-react-native-library/bin/create-react-native-library new-version \ + # --slug @bob/react-native-test \ + # --description test \ + # --author-name test \ + # --author-email test@test \ + # --author-url https://test.test \ + # --repo-url https://test.test \ + # --type module-mixed \ + # --languages java-objc \ + # --no-example \ + # --no-local + # + - name: Create new-version for now run: | - ./packages/create-react-native-library/bin/create-react-native-library new-version \ - --slug @bob/react-native-test \ - --description test \ - --author-name test \ - --author-email test@test \ - --author-url https://test.test \ - --repo-url https://test.test \ - --type module-mixed \ - --languages java-objc \ - --no-example \ - --no-local + mkdir new-version + cd new-version + echo "Hi mom!" > hey.txt + # For good measure + git init - name: Create the Differ repo run: | From 5a37d394bb9f7a0232e4d13460603880e0db0408 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 7 Oct 2023 08:54:21 +0300 Subject: [PATCH 042/137] chore: debug ssh address --- .github/workflows/comment-diffs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index c82585499..b20140fc7 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -47,6 +47,7 @@ jobs: - name: Create the Differ repo run: | + echo $DIFF_VIEW_SSH mkdir differ cd differ git init @@ -85,9 +86,8 @@ jobs: uses: cpina/github-action-push-to-another-repository@main env: SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY }} - API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }} with: - source-directory: 'output' + source-directory: 'new-version' destination-github-username: $DIFF_VIEW_USERNAME destination-repository-name: $DIFF_VIEW_REPO_NAME user-email: test@test.com From fe42250bbcc5270689e3d76474bf7ebd90ecbd45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 7 Oct 2023 08:58:33 +0300 Subject: [PATCH 043/137] chore: use context to get vars --- .github/workflows/comment-diffs.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index b20140fc7..efcddf3fa 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -47,11 +47,11 @@ jobs: - name: Create the Differ repo run: | - echo $DIFF_VIEW_SSH + echo ${{ vars.DIFF_VIEW_SSH }} mkdir differ cd differ git init - git remote add origin $DIFF_VIEW_SSH + git remote add origin ${{ vars.DIFF_VIEW_SSH }} desired_branch="new-version" # Check if the branch exists on the remote repository if git ls-remote --heads origin "$desired_branch" | grep -q "$desired_branch"; then @@ -88,8 +88,8 @@ jobs: SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY }} with: source-directory: 'new-version' - destination-github-username: $DIFF_VIEW_USERNAME - destination-repository-name: $DIFF_VIEW_REPO_NAME + destination-github-username: ${{ vars.DIFF_VIEW_USERNAME }} + destination-repository-name: ${{ vars.DIFF_VIEW_REPO_NAME }} user-email: test@test.com target-branch: new-version From 07fd0b32e593550a03b1cd71d8c771418a07787b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 7 Oct 2023 09:00:53 +0300 Subject: [PATCH 044/137] chore: add git config --- .github/workflows/comment-diffs.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index efcddf3fa..6c409ef41 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -13,8 +13,8 @@ jobs: comment-diffs: runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v3 + # - name: Checkout + # uses: actions/checkout@v3 # - name: Setup # uses: ./.github/actions/setup @@ -79,6 +79,8 @@ jobs: - name: Commit everything in differ run: | + git config --global user.email "text@test.com" + git config --global user.name "Github actions test" cd differ git add -A && git commit -m "Automatic commit" From 9f2a251209bdf38d7ca0ffcb852a0230e741fbfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 7 Oct 2023 09:04:36 +0300 Subject: [PATCH 045/137] chore: use ssh agent --- .github/workflows/comment-diffs.yml | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 6c409ef41..d3cc5d105 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -45,6 +45,11 @@ jobs: # For good measure git init + + - uses: webfactory/ssh-agent@v0.7.0 + with: + ssh-private-key: ${{ secrets.SSH_DEPLOY_KEY }} + - name: Create the Differ repo run: | echo ${{ vars.DIFF_VIEW_SSH }} @@ -83,17 +88,7 @@ jobs: git config --global user.name "Github actions test" cd differ git add -A && git commit -m "Automatic commit" - - - name: Pushes to another repository - uses: cpina/github-action-push-to-another-repository@main - env: - SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY }} - with: - source-directory: 'new-version' - destination-github-username: ${{ vars.DIFF_VIEW_USERNAME }} - destination-repository-name: ${{ vars.DIFF_VIEW_REPO_NAME }} - user-email: test@test.com - target-branch: new-version + git push # - name: Fetch main # run: git fetch origin main From f76ce15fce31573c5c43b424e76058098be24f02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 7 Oct 2023 09:05:29 +0300 Subject: [PATCH 046/137] chore: set upstream while pushing --- .github/workflows/comment-diffs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index d3cc5d105..4508d84a8 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -88,7 +88,7 @@ jobs: git config --global user.name "Github actions test" cd differ git add -A && git commit -m "Automatic commit" - git push + git push --set-upstream origin new-version # - name: Fetch main # run: git fetch origin main From 59c8f28ddb128e38f0b8d80a5a9ac43df3f6456d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 7 Oct 2023 09:10:58 +0300 Subject: [PATCH 047/137] chore: use old version --- .github/workflows/comment-diffs.yml | 47 +++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 4508d84a8..55fe59d9c 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -45,6 +45,13 @@ jobs: # For good measure git init + - name: Create old-version for now + run: | + mkdir old-version + cd old-version + echo "Hi mom, I'm old!" > hey.txt + # For good measure + git init - uses: webfactory/ssh-agent@v0.7.0 with: @@ -90,6 +97,46 @@ jobs: git add -A && git commit -m "Automatic commit" git push --set-upstream origin new-version + - name: Switch to old version repo + run: | + cd differ + desired_branch="old-version" + # Check if the branch exists on the remote repository + if git ls-remote --heads origin "$desired_branch" | grep -q "$desired_branch"; then + echo "The branch $desired_branch already exists on the remote repository." + git fetch origin "$desired_branch" # Fetch the branch from the remote + git checkout "$desired_branch" # Switch to the existing branch + else + echo "The branch $desired_branch does not exist on the remote repository." + git checkout -b "$desired_branch" # Create a new branch and switch to it + fi + + - name: Clean the Differ repo + run: | + cd differ + # Remove everything except the .git folder and it's contents. + for i in `ls | grep -v ".git"` ; do rm -rf $i; done; + + - name: Delete .git of old-version + run: | + rm -rf old-version/.git + + - name: Copy everything inside new-version to differ + run: | + cp old-version/* differ + + - name: Print diff + run: | + git diff old-version..new-version + + - name: Commit everything in differ + run: | + git config --global user.email "text@test.com" + git config --global user.name "Github actions test" + cd differ + git add -A && git commit -m "Automatic commit" + git push --set-upstream origin new-version + # - name: Fetch main # run: git fetch origin main # From 66d2e336c8019312760036c77450222be3b39719 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 7 Oct 2023 09:14:39 +0300 Subject: [PATCH 048/137] chore: dont fail if git didnt change --- .github/workflows/comment-diffs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 55fe59d9c..6bed9333c 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -94,7 +94,7 @@ jobs: git config --global user.email "text@test.com" git config --global user.name "Github actions test" cd differ - git add -A && git commit -m "Automatic commit" + git add -A || true && git commit -m "Automatic commit" || true git push --set-upstream origin new-version - name: Switch to old version repo @@ -134,7 +134,7 @@ jobs: git config --global user.email "text@test.com" git config --global user.name "Github actions test" cd differ - git add -A && git commit -m "Automatic commit" + git add -A || true && git commit -m "Automatic commit" || true git push --set-upstream origin new-version # - name: Fetch main From bc1416af275c718c73237f64a35366e150886dde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 7 Oct 2023 09:15:26 +0300 Subject: [PATCH 049/137] chore: fix diff --- .github/workflows/comment-diffs.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 6bed9333c..d1add812b 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -127,6 +127,7 @@ jobs: - name: Print diff run: | + cd differ git diff old-version..new-version - name: Commit everything in differ From b8ecccc25aed130a2670711deab4049305243bf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 7 Oct 2023 09:18:06 +0300 Subject: [PATCH 050/137] chore: fix upstream branch name --- .github/workflows/comment-diffs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index d1add812b..161a81acd 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -128,7 +128,7 @@ jobs: - name: Print diff run: | cd differ - git diff old-version..new-version + git diff old-version..new-version | cat - name: Commit everything in differ run: | @@ -136,7 +136,7 @@ jobs: git config --global user.name "Github actions test" cd differ git add -A || true && git commit -m "Automatic commit" || true - git push --set-upstream origin new-version + git push --set-upstream origin old-version # - name: Fetch main # run: git fetch origin main From 39b34fad2fc7a713549a3487e00a7d374bc056bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 7 Oct 2023 09:26:51 +0300 Subject: [PATCH 051/137] chore: print the github diff link --- .github/workflows/comment-diffs.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 161a81acd..754195f60 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -90,11 +90,13 @@ jobs: cp new-version/* differ - name: Commit everything in differ + id: commit-new run: | git config --global user.email "text@test.com" git config --global user.name "Github actions test" cd differ git add -A || true && git commit -m "Automatic commit" || true + echo "NEW_COMMIT_HASH$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT git push --set-upstream origin new-version - name: Switch to old version repo @@ -125,19 +127,20 @@ jobs: run: | cp old-version/* differ - - name: Print diff - run: | - cd differ - git diff old-version..new-version | cat - - name: Commit everything in differ + id: commit-old run: | git config --global user.email "text@test.com" git config --global user.name "Github actions test" cd differ git add -A || true && git commit -m "Automatic commit" || true + echo "OLD_COMMIT_HASH$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT git push --set-upstream origin old-version + - name: Print out the diff check url + run: | + echo "https://github.com/${{ vars.DIFF_VIEW_USERNAME }}${{ vars.DIFF_VIEW_REPO_NAME }}/compare${{ steps.commit-old.outputs.OLD_COMMIT_HASH }}..${{ steps.commit-new.outputs.NEW_COMMIT_HASH }}" + # - name: Fetch main # run: git fetch origin main # From 3823909b02bd47a149730d8883b0606253ceace0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 7 Oct 2023 09:28:04 +0300 Subject: [PATCH 052/137] chore: add = --- .github/workflows/comment-diffs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 754195f60..02f49fc53 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -96,7 +96,7 @@ jobs: git config --global user.name "Github actions test" cd differ git add -A || true && git commit -m "Automatic commit" || true - echo "NEW_COMMIT_HASH$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT + echo "NEW_COMMIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT git push --set-upstream origin new-version - name: Switch to old version repo @@ -134,7 +134,7 @@ jobs: git config --global user.name "Github actions test" cd differ git add -A || true && git commit -m "Automatic commit" || true - echo "OLD_COMMIT_HASH$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT + echo "OLD_COMMIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT git push --set-upstream origin old-version - name: Print out the diff check url From 16f8161c96e1fdf21415c45dacceb622864ca757 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 7 Oct 2023 09:30:33 +0300 Subject: [PATCH 053/137] chore: get commit hashes of remote --- .github/workflows/comment-diffs.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 02f49fc53..f3a833fad 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -96,8 +96,8 @@ jobs: git config --global user.name "Github actions test" cd differ git add -A || true && git commit -m "Automatic commit" || true - echo "NEW_COMMIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT git push --set-upstream origin new-version + echo "NEW_COMMIT_HASH=$(git rev-parse --short origin/new-version)" >> $GITHUB_OUTPUT - name: Switch to old version repo run: | @@ -134,12 +134,12 @@ jobs: git config --global user.name "Github actions test" cd differ git add -A || true && git commit -m "Automatic commit" || true - echo "OLD_COMMIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT git push --set-upstream origin old-version + echo "OLD_COMMIT_HASH=$(git rev-parse --short origin/old-version)" >> $GITHUB_OUTPUT - name: Print out the diff check url run: | - echo "https://github.com/${{ vars.DIFF_VIEW_USERNAME }}${{ vars.DIFF_VIEW_REPO_NAME }}/compare${{ steps.commit-old.outputs.OLD_COMMIT_HASH }}..${{ steps.commit-new.outputs.NEW_COMMIT_HASH }}" + echo "https://github.com/${{ vars.DIFF_VIEW_USERNAME }}${{ vars.DIFF_VIEW_REPO_NAME }}/compare/${{ steps.commit-old.outputs.OLD_COMMIT_HASH }}..${{ steps.commit-new.outputs.NEW_COMMIT_HASH }}" # - name: Fetch main # run: git fetch origin main From 1d9cf9746091a50e41acc7776d2d8f8c2492697c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 7 Oct 2023 09:31:58 +0300 Subject: [PATCH 054/137] chore: add missing / :) --- .github/workflows/comment-diffs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index f3a833fad..72083a4fa 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -139,7 +139,7 @@ jobs: - name: Print out the diff check url run: | - echo "https://github.com/${{ vars.DIFF_VIEW_USERNAME }}${{ vars.DIFF_VIEW_REPO_NAME }}/compare/${{ steps.commit-old.outputs.OLD_COMMIT_HASH }}..${{ steps.commit-new.outputs.NEW_COMMIT_HASH }}" + echo "https://github.com/${{ vars.DIFF_VIEW_USERNAME }}/${{ vars.DIFF_VIEW_REPO_NAME }}/compare/${{ steps.commit-old.outputs.OLD_COMMIT_HASH }}..${{ steps.commit-new.outputs.NEW_COMMIT_HASH }}" # - name: Fetch main # run: git fetch origin main From 9edccdd9942aa7a72047a303a2277f8e06ddcc3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 7 Oct 2023 09:37:29 +0300 Subject: [PATCH 055/137] chore: comment on PR --- .github/workflows/comment-diffs.yml | 139 ++++++++++++++-------------- 1 file changed, 71 insertions(+), 68 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 72083a4fa..67ec06520 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -11,47 +11,60 @@ on: jobs: comment-diffs: - runs-on: ubuntu-latest + runs-on: macos-latest steps: - # - name: Checkout - # uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v3 - # - name: Setup + - name: Setup + uses: ./.github/actions/setup + + - name: Build crnl + run: | + yarn workspace create-react-native-library prepare + + - name: Create library + run: | + ./packages/create-react-native-library/bin/create-react-native-library new-version \ + --slug @bob/react-native-test \ + --description test \ + --author-name test \ + --author-email test@test \ + --author-url https://test.test \ + --repo-url https://test.test \ + --type module-mixed \ + --languages java-objc \ + --no-example \ + --no-local + + - name: Fetch main + run: git fetch origin main + + - name: Checkout main + run: git checkout origin/main + + # Removed this step for the sake of testing + # - name: Setup again # Add a check here to setup again if deps changed # uses: ./.github/actions/setup - # - # - name: Build crnl - # run: | - # yarn workspace create-react-native-library prepare - # - # - name: Create library - # run: | - # ./packages/create-react-native-library/bin/create-react-native-library new-version \ - # --slug @bob/react-native-test \ - # --description test \ - # --author-name test \ - # --author-email test@test \ - # --author-url https://test.test \ - # --repo-url https://test.test \ - # --type module-mixed \ - # --languages java-objc \ - # --no-example \ - # --no-local - # - - name: Create new-version for now + + - name: Remove old build and build again run: | - mkdir new-version - cd new-version - echo "Hi mom!" > hey.txt - # For good measure - git init - - - name: Create old-version for now + rm -rf ./packages/create-react-native-library/lib + yarn workspace create-react-native-library prepare + + - name: Create library again run: | - mkdir old-version - cd old-version - echo "Hi mom, I'm old!" > hey.txt - # For good measure - git init + ./packages/create-react-native-library/bin/create-react-native-library old-version \ + --slug @bob/react-native-test \ + --description test \ + --author-name test \ + --author-email test@test \ + --author-url https://test.test \ + --repo-url https://test.test \ + --type module-mixed \ + --languages java-objc \ + --no-example \ + --no-local - uses: webfactory/ssh-agent@v0.7.0 with: @@ -137,35 +150,25 @@ jobs: git push --set-upstream origin old-version echo "OLD_COMMIT_HASH=$(git rev-parse --short origin/old-version)" >> $GITHUB_OUTPUT - - name: Print out the diff check url - run: | - echo "https://github.com/${{ vars.DIFF_VIEW_USERNAME }}/${{ vars.DIFF_VIEW_REPO_NAME }}/compare/${{ steps.commit-old.outputs.OLD_COMMIT_HASH }}..${{ steps.commit-new.outputs.NEW_COMMIT_HASH }}" - - # - name: Fetch main - # run: git fetch origin main - # - # - name: Checkout main - # run: git checkout origin/main - # - # # Removed this step for the sake of testing - # # - name: Setup again # Add a check here to setup again if deps changed - # # uses: ./.github/actions/setup - # - # - name: Remove old build and build again - # run: | - # rm -rf ./packages/create-react-native-library/lib - # yarn workspace create-react-native-library prepare - # - # - name: Create library again - # run: | - # ./packages/create-react-native-library/bin/create-react-native-library old-version \ - # --slug @bob/react-native-test \ - # --description test \ - # --author-name test \ - # --author-email test@test \ - # --author-url https://test.test \ - # --repo-url https://test.test \ - # --type module-mixed \ - # --languages java-objc \ - # --no-example \ - # --no-local + - name: Comment on PR + uses: actions/github-script@v3 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + const body = `This PR changes the output of \`create-react-native-library\`. You can find the diff of the change [here](https://github.com/${{ vars.DIFF_VIEW_USERNAME }}/${{ vars.DIFF_VIEW_REPO_NAME }}/compare/${{ steps.commit-old.outputs.OLD_COMMIT_HASH }}..${{ steps.commit-new.outputs.NEW_COMMIT_HASH }})`; + + const comments = await github.issues.listComments({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + }); + if (comments.data.some(comment => comment.body === body)) { + return; + } + github.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body + }) + From 6a485000b24b88ec2f0c47895ca659806b8547c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 7 Oct 2023 09:39:42 +0300 Subject: [PATCH 056/137] chore: use copy with -r --- .github/workflows/comment-diffs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 67ec06520..4dd75c4ae 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -100,7 +100,7 @@ jobs: - name: Copy everything inside new-version to differ run: | - cp new-version/* differ + cp -r new-version/* differ - name: Commit everything in differ id: commit-new @@ -138,7 +138,7 @@ jobs: - name: Copy everything inside new-version to differ run: | - cp old-version/* differ + cp -r old-version/* differ - name: Commit everything in differ id: commit-old From cb4f26eea02c416a99a7e2a324435ffc82535d56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 7 Oct 2023 09:45:18 +0300 Subject: [PATCH 057/137] chore: echo url --- .github/workflows/comment-diffs.yml | 46 ++++++++++++++++------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 4dd75c4ae..89a1671a1 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -150,25 +150,29 @@ jobs: git push --set-upstream origin old-version echo "OLD_COMMIT_HASH=$(git rev-parse --short origin/old-version)" >> $GITHUB_OUTPUT - - name: Comment on PR - uses: actions/github-script@v3 - with: - github-token: ${{secrets.GITHUB_TOKEN}} - script: | - const body = `This PR changes the output of \`create-react-native-library\`. You can find the diff of the change [here](https://github.com/${{ vars.DIFF_VIEW_USERNAME }}/${{ vars.DIFF_VIEW_REPO_NAME }}/compare/${{ steps.commit-old.outputs.OLD_COMMIT_HASH }}..${{ steps.commit-new.outputs.NEW_COMMIT_HASH }})`; + - name: Echo change url + run: | + echo "https://github.com/${{ vars.DIFF_VIEW_USERNAME }}/${{ vars.DIFF_VIEW_REPO_NAME }}/compare/${{ steps.commit-old.outputs.OLD_COMMIT_HASH }}..${{ steps.commit-new.outputs.NEW_COMMIT_HASH }}" - const comments = await github.issues.listComments({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - }); - if (comments.data.some(comment => comment.body === body)) { - return; - } - github.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body - }) - + # - name: Comment on PR + # uses: actions/github-script@v3 + # with: + # github-token: ${{secrets.GITHUB_TOKEN}} + # script: | + # const body = `This PR changes the output of \`create-react-native-library\`. You can find the diff of the change [here](https://github.com/${{ vars.DIFF_VIEW_USERNAME }}/${{ vars.DIFF_VIEW_REPO_NAME }}/compare/${{ steps.commit-old.outputs.OLD_COMMIT_HASH }}..${{ steps.commit-new.outputs.NEW_COMMIT_HASH }})`; + # + # const comments = await github.issues.listComments({ + # issue_number: context.issue.number, + # owner: context.repo.owner, + # repo: context.repo.repo, + # }); + # if (comments.data.some(comment => comment.body === body)) { + # return; + # } + # github.issues.createComment({ + # issue_number: context.issue.number, + # owner: context.repo.owner, + # repo: context.repo.repo, + # body + # }) + # From b6a572c4d9e7153384e3c0f733a7ecd42513ac08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 7 Oct 2023 09:54:33 +0300 Subject: [PATCH 058/137] chore: add branch prefix --- .github/workflows/comment-diffs.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 89a1671a1..12bfcb549 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -66,6 +66,11 @@ jobs: --no-example \ --no-local + - name: Set Diff view branch prefix env + run: | + PR_NUMBER=$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }') + echo "BRANCH_PREFIX=$($PR_NUMBER)-type-languages" >> $GITHUB_ENV + - uses: webfactory/ssh-agent@v0.7.0 with: ssh-private-key: ${{ secrets.SSH_DEPLOY_KEY }} @@ -77,7 +82,7 @@ jobs: cd differ git init git remote add origin ${{ vars.DIFF_VIEW_SSH }} - desired_branch="new-version" + desired_branch="${{ env.BRANCH_PREFIX }}-new-version" # Check if the branch exists on the remote repository if git ls-remote --heads origin "$desired_branch" | grep -q "$desired_branch"; then echo "The branch $desired_branch already exists on the remote repository." @@ -115,7 +120,7 @@ jobs: - name: Switch to old version repo run: | cd differ - desired_branch="old-version" + desired_branch="${{ env.BRANCH_PREFIX }}-old-version" # Check if the branch exists on the remote repository if git ls-remote --heads origin "$desired_branch" | grep -q "$desired_branch"; then echo "The branch $desired_branch already exists on the remote repository." From 4c824cad4a52866b6ff9ef98883a990d151f5899 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 7 Oct 2023 09:58:16 +0300 Subject: [PATCH 059/137] chore: change pr number method --- .github/workflows/comment-diffs.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 12bfcb549..08b39c2df 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -68,8 +68,7 @@ jobs: - name: Set Diff view branch prefix env run: | - PR_NUMBER=$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }') - echo "BRANCH_PREFIX=$($PR_NUMBER)-type-languages" >> $GITHUB_ENV + echo "BRANCH_PREFIX=${{ github.event.number }}-type-languages" >> $GITHUB_ENV - uses: webfactory/ssh-agent@v0.7.0 with: From 28e882f6f71aef501862c0b92fc15ea0cd732b06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 7 Oct 2023 10:04:59 +0300 Subject: [PATCH 060/137] chore: change branch prefixes --- .github/workflows/comment-diffs.yml | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 08b39c2df..f3a227a62 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -68,7 +68,9 @@ jobs: - name: Set Diff view branch prefix env run: | - echo "BRANCH_PREFIX=${{ github.event.number }}-type-languages" >> $GITHUB_ENV + BRANCH_PREFIX="${{ github.event.number }}-type-languages" + echo "OLD_VERSION_BRANCH=$($BRANCH_PREFIX)-old-version" >> $GITHUB_ENV + echo "NEW_VERSION_BRANCH=$($BRANCH_PREFIX)-new-version" >> $GITHUB_ENV - uses: webfactory/ssh-agent@v0.7.0 with: @@ -81,7 +83,7 @@ jobs: cd differ git init git remote add origin ${{ vars.DIFF_VIEW_SSH }} - desired_branch="${{ env.BRANCH_PREFIX }}-new-version" + desired_branch="${{ env.NEW_VERSION_BRANCH }}" # Check if the branch exists on the remote repository if git ls-remote --heads origin "$desired_branch" | grep -q "$desired_branch"; then echo "The branch $desired_branch already exists on the remote repository." @@ -113,13 +115,13 @@ jobs: git config --global user.name "Github actions test" cd differ git add -A || true && git commit -m "Automatic commit" || true - git push --set-upstream origin new-version - echo "NEW_COMMIT_HASH=$(git rev-parse --short origin/new-version)" >> $GITHUB_OUTPUT + git push --set-upstream origin ${{ env.NEW_VERSION_BRANCH }} + echo "NEW_COMMIT_HASH=$(git rev-parse --short origin/${{ env.NEW_VERSION_BRANCH }})" >> $GITHUB_OUTPUT - name: Switch to old version repo run: | cd differ - desired_branch="${{ env.BRANCH_PREFIX }}-old-version" + desired_branch="${{ env.OLD_VERSION_BRANCH }}" # Check if the branch exists on the remote repository if git ls-remote --heads origin "$desired_branch" | grep -q "$desired_branch"; then echo "The branch $desired_branch already exists on the remote repository." @@ -151,8 +153,8 @@ jobs: git config --global user.name "Github actions test" cd differ git add -A || true && git commit -m "Automatic commit" || true - git push --set-upstream origin old-version - echo "OLD_COMMIT_HASH=$(git rev-parse --short origin/old-version)" >> $GITHUB_OUTPUT + git push --set-upstream origin ${{ env.OLD_VERSION_BRANCH }} + echo "OLD_COMMIT_HASH=$(git rev-parse --short origin/${{ env.OLD_VERSION_BRANCH }})" >> $GITHUB_OUTPUT - name: Echo change url run: | From 95171c416884d47d567b60799737c5cc8b26f5d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 7 Oct 2023 10:07:09 +0300 Subject: [PATCH 061/137] chore: fix syntax --- .github/workflows/comment-diffs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index f3a227a62..869a4fc78 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -69,8 +69,8 @@ jobs: - name: Set Diff view branch prefix env run: | BRANCH_PREFIX="${{ github.event.number }}-type-languages" - echo "OLD_VERSION_BRANCH=$($BRANCH_PREFIX)-old-version" >> $GITHUB_ENV - echo "NEW_VERSION_BRANCH=$($BRANCH_PREFIX)-new-version" >> $GITHUB_ENV + echo "OLD_VERSION_BRANCH=$(BRANCH_PREFIX)-old-version" >> $GITHUB_ENV + echo "NEW_VERSION_BRANCH=$(BRANCH_PREFIX)-new-version" >> $GITHUB_ENV - uses: webfactory/ssh-agent@v0.7.0 with: From 1921a3b25b3fcda05a714c14c137ea40542c99bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 7 Oct 2023 10:10:49 +0300 Subject: [PATCH 062/137] chore: fix prefix --- .github/workflows/comment-diffs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 869a4fc78..b790b883d 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -69,8 +69,8 @@ jobs: - name: Set Diff view branch prefix env run: | BRANCH_PREFIX="${{ github.event.number }}-type-languages" - echo "OLD_VERSION_BRANCH=$(BRANCH_PREFIX)-old-version" >> $GITHUB_ENV - echo "NEW_VERSION_BRANCH=$(BRANCH_PREFIX)-new-version" >> $GITHUB_ENV + echo "OLD_VERSION_BRANCH=$BRANCH_PREFIX-old-version" >> $GITHUB_ENV + echo "NEW_VERSION_BRANCH=$BRANCH_PREFIX-new-version" >> $GITHUB_ENV - uses: webfactory/ssh-agent@v0.7.0 with: From f649673a6f4da9a9b18cd85992354a9d6a9083a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 7 Oct 2023 10:20:16 +0300 Subject: [PATCH 063/137] chore: add matrix --- .github/workflows/comment-diffs.yml | 63 ++++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index b790b883d..fd039cc45 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -11,6 +11,43 @@ on: jobs: comment-diffs: + strategy: + fail-fast: false + matrix: + type: + - module-legacy + - module-mixed + - module-new + - view-legacy + - view-mixed + - view-new + language: + - java-objc + - java-swift + - kotlin-objc + - kotlin-swift + exclude: + - type: module-new + language: java-swift + - type: module-new + language: kotlin-swift + - type: module-mixed + language: java-swift + - type: module-mixed + language: kotlin-swift + - type: view-new + language: java-swift + - type: view-new + language: kotlin-swift + - type: view-mixed + language: java-swift + - type: view-mixed + language: kotlin-swift + + concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.type }}-${{ matrix.language }} + cancel-in-progress: true + runs-on: macos-latest steps: - name: Checkout @@ -158,7 +195,31 @@ jobs: - name: Echo change url run: | - echo "https://github.com/${{ vars.DIFF_VIEW_USERNAME }}/${{ vars.DIFF_VIEW_REPO_NAME }}/compare/${{ steps.commit-old.outputs.OLD_COMMIT_HASH }}..${{ steps.commit-new.outputs.NEW_COMMIT_HASH }}" + + - name: Write changes to common file + run: | + mkdir -p pipelines + echo "https://github.com/${{ vars.DIFF_VIEW_USERNAME }}/${{ vars.DIFF_VIEW_REPO_NAME }}/compare/${{ steps.commit-old.outputs.OLD_COMMIT_HASH }}..${{ steps.commit-new.outputs.NEW_COMMIT_HASH }}" >> outputs/${{ matrix.type }}-${{ matrix.language }}.txt + + - uses: actions/upload-artifact@v3 + with: + name: outputs + path: outputs/*.txt + + read-values: + runs-on: ubuntu-latest + needs: [comment-diffs] + steps: + - uses: actions/checkout@v3 + - name: Load outputs + uses: actions/download-artifact@v3 + with: + name: outputs + path: outputs + + - run: | + ls outputs + cat outputs/*.txt # - name: Comment on PR # uses: actions/github-script@v3 From 66ec847af12822c9b35ec1f1b356923a14d72044 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 7 Oct 2023 10:24:04 +0300 Subject: [PATCH 064/137] chore: init libs correctly --- .github/workflows/comment-diffs.yml | 59 +++++++++++++++-------------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index fd039cc45..5d078a5b3 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -16,38 +16,39 @@ jobs: matrix: type: - module-legacy - - module-mixed - - module-new + # - module-mixed + # - module-new - view-legacy - - view-mixed - - view-new + # - view-mixed + # - view-new language: - java-objc - - java-swift - - kotlin-objc - - kotlin-swift - exclude: - - type: module-new - language: java-swift - - type: module-new - language: kotlin-swift - - type: module-mixed - language: java-swift - - type: module-mixed - language: kotlin-swift - - type: view-new - language: java-swift - - type: view-new - language: kotlin-swift - - type: view-mixed - language: java-swift - - type: view-mixed - language: kotlin-swift + # - java-swift + # - kotlin-objc + # - kotlin-swift + # exclude: + # - type: module-new + # language: java-swift + # - type: module-new + # language: kotlin-swift + # - type: module-mixed + # language: java-swift + # - type: module-mixed + # language: kotlin-swift + # - type: view-new + # language: java-swift + # - type: view-new + # language: kotlin-swift + # - type: view-mixed + # language: java-swift + # - type: view-mixed + # language: kotlin-swift concurrency: group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.type }}-${{ matrix.language }} cancel-in-progress: true + # TODO: use ubuntu once CLI is fixed runs-on: macos-latest steps: - name: Checkout @@ -69,8 +70,8 @@ jobs: --author-email test@test \ --author-url https://test.test \ --repo-url https://test.test \ - --type module-mixed \ - --languages java-objc \ + --type ${{ matrix.type }} \ + --languages ${{ matrix.language }} \ --no-example \ --no-local @@ -98,14 +99,14 @@ jobs: --author-email test@test \ --author-url https://test.test \ --repo-url https://test.test \ - --type module-mixed \ - --languages java-objc \ + --type ${{ matrix.type }} \ + --languages ${{ matrix.language }} \ --no-example \ --no-local - name: Set Diff view branch prefix env run: | - BRANCH_PREFIX="${{ github.event.number }}-type-languages" + BRANCH_PREFIX="${{ github.event.number }}-${{ matrix.type }}-${{ matrix.language }}" echo "OLD_VERSION_BRANCH=$BRANCH_PREFIX-old-version" >> $GITHUB_ENV echo "NEW_VERSION_BRANCH=$BRANCH_PREFIX-new-version" >> $GITHUB_ENV From 02baa78c99e639c7c0673a986700b6d1470d0792 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 7 Oct 2023 10:27:05 +0300 Subject: [PATCH 065/137] chore: generate folder --- .github/workflows/comment-diffs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 5d078a5b3..a3a9d9f9b 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -199,7 +199,7 @@ jobs: - name: Write changes to common file run: | - mkdir -p pipelines + mkdir outputs echo "https://github.com/${{ vars.DIFF_VIEW_USERNAME }}/${{ vars.DIFF_VIEW_REPO_NAME }}/compare/${{ steps.commit-old.outputs.OLD_COMMIT_HASH }}..${{ steps.commit-new.outputs.NEW_COMMIT_HASH }}" >> outputs/${{ matrix.type }}-${{ matrix.language }}.txt - uses: actions/upload-artifact@v3 From 338b4686844ce6f666d1917a007b0365d5a38b69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 7 Oct 2023 10:33:53 +0300 Subject: [PATCH 066/137] chore: change the diff --- .github/workflows/comment-diffs.yml | 3 --- .../templates/common/babel.config.js | 1 - .../{%- project.package_dir %}/{%- project.name %}Module.java | 1 + .../{%- project.package_dir %}/{%- project.name %}Module.java | 1 - 4 files changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index a3a9d9f9b..650a12e09 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -194,9 +194,6 @@ jobs: git push --set-upstream origin ${{ env.OLD_VERSION_BRANCH }} echo "OLD_COMMIT_HASH=$(git rev-parse --short origin/${{ env.OLD_VERSION_BRANCH }})" >> $GITHUB_OUTPUT - - name: Echo change url - run: | - - name: Write changes to common file run: | mkdir outputs diff --git a/packages/create-react-native-library/templates/common/babel.config.js b/packages/create-react-native-library/templates/common/babel.config.js index 718da07e1..f842b77fc 100644 --- a/packages/create-react-native-library/templates/common/babel.config.js +++ b/packages/create-react-native-library/templates/common/babel.config.js @@ -1,4 +1,3 @@ module.exports = { - // Hi mom! presets: ['module:metro-react-native-babel-preset'], }; diff --git a/packages/create-react-native-library/templates/java-library-legacy/android/src/main/java/com/{%- project.package_dir %}/{%- project.name %}Module.java b/packages/create-react-native-library/templates/java-library-legacy/android/src/main/java/com/{%- project.package_dir %}/{%- project.name %}Module.java index 98948119c..6c8fd43cc 100644 --- a/packages/create-react-native-library/templates/java-library-legacy/android/src/main/java/com/{%- project.package_dir %}/{%- project.name %}Module.java +++ b/packages/create-react-native-library/templates/java-library-legacy/android/src/main/java/com/{%- project.package_dir %}/{%- project.name %}Module.java @@ -8,6 +8,7 @@ import com.facebook.react.bridge.ReactMethod; import com.facebook.react.module.annotations.ReactModule; +// Hi mom! Is this thing on? @ReactModule(name = <%- project.name -%>Module.NAME) public class <%- project.name -%>Module extends ReactContextBaseJavaModule { public static final String NAME = "<%- project.name -%>"; diff --git a/packages/create-react-native-library/templates/java-library-mixed/android/src/main/java/com/{%- project.package_dir %}/{%- project.name %}Module.java b/packages/create-react-native-library/templates/java-library-mixed/android/src/main/java/com/{%- project.package_dir %}/{%- project.name %}Module.java index 01465a217..6cb6c2d05 100644 --- a/packages/create-react-native-library/templates/java-library-mixed/android/src/main/java/com/{%- project.package_dir %}/{%- project.name %}Module.java +++ b/packages/create-react-native-library/templates/java-library-mixed/android/src/main/java/com/{%- project.package_dir %}/{%- project.name %}Module.java @@ -6,7 +6,6 @@ import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactMethod; -// Hi mom! public class <%- project.name -%>Module extends <%- project.name -%>Spec { public static final String NAME = "<%- project.name -%>"; From 7cd895c937eb0f872a4133659c85fdd227dc1b37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 7 Oct 2023 11:00:14 +0300 Subject: [PATCH 067/137] chore: conditionally push diffs --- .github/workflows/comment-diffs.yml | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 650a12e09..1e8970bff 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -153,8 +153,6 @@ jobs: git config --global user.name "Github actions test" cd differ git add -A || true && git commit -m "Automatic commit" || true - git push --set-upstream origin ${{ env.NEW_VERSION_BRANCH }} - echo "NEW_COMMIT_HASH=$(git rev-parse --short origin/${{ env.NEW_VERSION_BRANCH }})" >> $GITHUB_OUTPUT - name: Switch to old version repo run: | @@ -185,21 +183,41 @@ jobs: cp -r old-version/* differ - name: Commit everything in differ - id: commit-old run: | git config --global user.email "text@test.com" git config --global user.name "Github actions test" cd differ git add -A || true && git commit -m "Automatic commit" || true + + + - name: Check if the diff is non-empty + id: check-is-diff-non-empty + run: | + if git diff --quiet ${{ env.OLD_VERSION_BRANCH }}..${{ env.NEW_VERSION_BRANCH }}; then + result=0 # Diff is empty + else + result=1 # Diff is not empty + fi + echo "DIFF_IS_NON_EMPTY=$result" >> $GITHUB_OUTPUT + + - name: Push repos + if: ${{ steps.check-is-diff-non-empty.outputs.DIFF_IS_NON_EMPTY == '1' }} + id: push + run: | git push --set-upstream origin ${{ env.OLD_VERSION_BRANCH }} echo "OLD_COMMIT_HASH=$(git rev-parse --short origin/${{ env.OLD_VERSION_BRANCH }})" >> $GITHUB_OUTPUT + git switch ${{ env.NEW_VERSION_BRANCH }} + git push --set-upstream origin ${{ env.NEW_VERSION_BRANCH }} + echo "NEW_COMMIT_HASH=$(git rev-parse --short origin/${{ env.NEW_VERSION_BRANCH }})" >> $GITHUB_OUTPUT - name: Write changes to common file + if: ${{ steps.check-is-diff-non-empty.outputs.DIFF_IS_NON_EMPTY == '1' }} run: | mkdir outputs - echo "https://github.com/${{ vars.DIFF_VIEW_USERNAME }}/${{ vars.DIFF_VIEW_REPO_NAME }}/compare/${{ steps.commit-old.outputs.OLD_COMMIT_HASH }}..${{ steps.commit-new.outputs.NEW_COMMIT_HASH }}" >> outputs/${{ matrix.type }}-${{ matrix.language }}.txt + echo "https://github.com/${{ vars.DIFF_VIEW_USERNAME }}/${{ vars.DIFF_VIEW_REPO_NAME }}/compare/${{ steps.push.outputs.OLD_COMMIT_HASH }}..${{ steps.push.outputs.NEW_COMMIT_HASH }}" >> outputs/${{ matrix.type }}-${{ matrix.language }}.txt - uses: actions/upload-artifact@v3 + if: ${{ steps.check-is-diff-non-empty.outputs.DIFF_IS_NON_EMPTY == '1' }} with: name: outputs path: outputs/*.txt @@ -220,11 +238,12 @@ jobs: cat outputs/*.txt # - name: Comment on PR + # if: output is not empty # uses: actions/github-script@v3 # with: # github-token: ${{secrets.GITHUB_TOKEN}} # script: | - # const body = `This PR changes the output of \`create-react-native-library\`. You can find the diff of the change [here](https://github.com/${{ vars.DIFF_VIEW_USERNAME }}/${{ vars.DIFF_VIEW_REPO_NAME }}/compare/${{ steps.commit-old.outputs.OLD_COMMIT_HASH }}..${{ steps.commit-new.outputs.NEW_COMMIT_HASH }})`; + # const body = `This PR changes the output of \`create-react-native-library\`. You can find the diff of the change [here](https://github.com/${{ vars.DIFF_VIEW_USERNAME }}/${{ vars.DIFF_VIEW_REPO_NAME }}/compare/${{ steps.push.outputs.OLD_COMMIT_HASH }}..${{ steps.push.outputs.NEW_COMMIT_HASH }})`; # # const comments = await github.issues.listComments({ # issue_number: context.issue.number, From ce136830631577a695ed7edbc5223d4e3db16508 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 7 Oct 2023 11:04:45 +0300 Subject: [PATCH 068/137] chore: use script to switch branch --- .github/workflows/comment-diffs.yml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 1e8970bff..b08dce453 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -206,7 +206,18 @@ jobs: run: | git push --set-upstream origin ${{ env.OLD_VERSION_BRANCH }} echo "OLD_COMMIT_HASH=$(git rev-parse --short origin/${{ env.OLD_VERSION_BRANCH }})" >> $GITHUB_OUTPUT - git switch ${{ env.NEW_VERSION_BRANCH }} + + desired_branch="${{ env.NEW_VERSION_BRANCH }}" + # Check if the branch exists on the remote repository + if git ls-remote --heads origin "$desired_branch" | grep -q "$desired_branch"; then + echo "The branch $desired_branch already exists on the remote repository." + git fetch origin "$desired_branch" # Fetch the branch from the remote + git checkout "$desired_branch" # Switch to the existing branch + else + echo "The branch $desired_branch does not exist on the remote repository." + git checkout -b "$desired_branch" # Create a new branch and switch to it + fi + git push --set-upstream origin ${{ env.NEW_VERSION_BRANCH }} echo "NEW_COMMIT_HASH=$(git rev-parse --short origin/${{ env.NEW_VERSION_BRANCH }})" >> $GITHUB_OUTPUT From 94d04485ffdcbeadb5086fa255bf9b03c90a9009 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 7 Oct 2023 11:11:19 +0300 Subject: [PATCH 069/137] chore: add cd --- .github/workflows/comment-diffs.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index b08dce453..6209c8d06 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -193,6 +193,7 @@ jobs: - name: Check if the diff is non-empty id: check-is-diff-non-empty run: | + cd differ if git diff --quiet ${{ env.OLD_VERSION_BRANCH }}..${{ env.NEW_VERSION_BRANCH }}; then result=0 # Diff is empty else @@ -204,6 +205,7 @@ jobs: if: ${{ steps.check-is-diff-non-empty.outputs.DIFF_IS_NON_EMPTY == '1' }} id: push run: | + cd differ git push --set-upstream origin ${{ env.OLD_VERSION_BRANCH }} echo "OLD_COMMIT_HASH=$(git rev-parse --short origin/${{ env.OLD_VERSION_BRANCH }})" >> $GITHUB_OUTPUT From 3a5bcd4e1938417466cc85f13ae31d7050319c71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 7 Oct 2023 11:17:23 +0300 Subject: [PATCH 070/137] chore: remove switch script --- .github/workflows/comment-diffs.yml | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 6209c8d06..33bdde3b7 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -208,18 +208,7 @@ jobs: cd differ git push --set-upstream origin ${{ env.OLD_VERSION_BRANCH }} echo "OLD_COMMIT_HASH=$(git rev-parse --short origin/${{ env.OLD_VERSION_BRANCH }})" >> $GITHUB_OUTPUT - - desired_branch="${{ env.NEW_VERSION_BRANCH }}" - # Check if the branch exists on the remote repository - if git ls-remote --heads origin "$desired_branch" | grep -q "$desired_branch"; then - echo "The branch $desired_branch already exists on the remote repository." - git fetch origin "$desired_branch" # Fetch the branch from the remote - git checkout "$desired_branch" # Switch to the existing branch - else - echo "The branch $desired_branch does not exist on the remote repository." - git checkout -b "$desired_branch" # Create a new branch and switch to it - fi - + git checkout ${{ env.NEW_VERSION_BRANCH }} git push --set-upstream origin ${{ env.NEW_VERSION_BRANCH }} echo "NEW_COMMIT_HASH=$(git rev-parse --short origin/${{ env.NEW_VERSION_BRANCH }})" >> $GITHUB_OUTPUT From 7a9d4d039e566053914c1f72ad5afba086c72781 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 7 Oct 2023 11:34:18 +0300 Subject: [PATCH 071/137] chore: comment diff links if they are non empty --- .github/workflows/comment-diffs.yml | 65 +++++++++++++++++------------ 1 file changed, 39 insertions(+), 26 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 33bdde3b7..ca9496485 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -235,30 +235,43 @@ jobs: name: outputs path: outputs - - run: | - ls outputs - cat outputs/*.txt + - name: Output artifacts + id: artifacts + run: | + if ls outputs/*.txt; then + result=1 # Artifacts are not empty + echo "ARTIFACTS<> $GITHUB_OUTPUT + cat outputs/*.txt >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + + else + result=0 # Artifacts are empty + fi - # - name: Comment on PR - # if: output is not empty - # uses: actions/github-script@v3 - # with: - # github-token: ${{secrets.GITHUB_TOKEN}} - # script: | - # const body = `This PR changes the output of \`create-react-native-library\`. You can find the diff of the change [here](https://github.com/${{ vars.DIFF_VIEW_USERNAME }}/${{ vars.DIFF_VIEW_REPO_NAME }}/compare/${{ steps.push.outputs.OLD_COMMIT_HASH }}..${{ steps.push.outputs.NEW_COMMIT_HASH }})`; - # - # const comments = await github.issues.listComments({ - # issue_number: context.issue.number, - # owner: context.repo.owner, - # repo: context.repo.repo, - # }); - # if (comments.data.some(comment => comment.body === body)) { - # return; - # } - # github.issues.createComment({ - # issue_number: context.issue.number, - # owner: context.repo.owner, - # repo: context.repo.repo, - # body - # }) - # + echo "ARTIFACTS_ARE_NON_EMPTY=$result" >> $GITHUB_OUTPUT + + - name: Comment on PR + if: ${{ steps.artifacts.outputs.ARTIFACTS_ARE_NON_EMPTY == '1' }} + uses: actions/github-script@v3 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + const body = `This PR changes the output of \`create-react-native-library\`. You can find the diff of the changes below: + ${{ steps.artifacts.outputs.ARTIFACTS }} + `; + + const comments = await github.issues.listComments({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + }); + if (comments.data.some(comment => comment.body === body)) { + return; + } + github.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body + }) + From 0565764c37b5c6f9052ac598f91490aa7235947d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 7 Oct 2023 11:55:32 +0300 Subject: [PATCH 072/137] chore: add formatting --- .github/workflows/comment-diffs.yml | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index ca9496485..b7b916260 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -216,7 +216,7 @@ jobs: if: ${{ steps.check-is-diff-non-empty.outputs.DIFF_IS_NON_EMPTY == '1' }} run: | mkdir outputs - echo "https://github.com/${{ vars.DIFF_VIEW_USERNAME }}/${{ vars.DIFF_VIEW_REPO_NAME }}/compare/${{ steps.push.outputs.OLD_COMMIT_HASH }}..${{ steps.push.outputs.NEW_COMMIT_HASH }}" >> outputs/${{ matrix.type }}-${{ matrix.language }}.txt + echo "${{ matrix.language }} - ${{ matrix.type }}: https://github.com/${{ vars.DIFF_VIEW_USERNAME }}/${{ vars.DIFF_VIEW_REPO_NAME }}/compare/${{ steps.push.outputs.OLD_COMMIT_HASH }}..${{ steps.push.outputs.NEW_COMMIT_HASH }}" >> outputs/${{ matrix.type }}-${{ matrix.language }}.txt - uses: actions/upload-artifact@v3 if: ${{ steps.check-is-diff-non-empty.outputs.DIFF_IS_NON_EMPTY == '1' }} @@ -256,8 +256,27 @@ jobs: with: github-token: ${{secrets.GITHUB_TOKEN}} script: | - const body = `This PR changes the output of \`create-react-native-library\`. You can find the diff of the changes below: - ${{ steps.artifacts.outputs.ARTIFACTS }} + const replaceTable = { + "module-legacy": "**Native module**", + "module-mixed": "**Turbo module with backward compat**", + "module-new": "**Turbo module**", + "view-legacy": "**Native view**", + "view-mixed": "**Fabric view with backward compat**", + "view-new": "**Fabric view**", + "java-objc": "**Java and Objective C**", + "java-swift": "**Java and Swift**", + "kotlin-objc": "**Kotlin and Objective C**", + "kotlin-swift": "**Kotlin and Swift**" + } + + const artifacts = `${{ steps.artifacts.outputs.ARTIFACTS }}`; + + const artifactsReplaced = Object.entries(replaceTable).reduce((acc, [key, value]) => { + return acc.replace(new RegExp(key, "g"), value); + }, artifacts) + + const body = `🤓☝️ This PR changes the output of \`create-react-native-library\`. You can find the diff of the changes below: + ${artifactsReplaced} `; const comments = await github.issues.listComments({ From 9b16757dc75fcbb92ac940d181d1416fc0e1fcb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 7 Oct 2023 11:56:20 +0300 Subject: [PATCH 073/137] chore: add link for formatting --- .github/workflows/comment-diffs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index b7b916260..6e950e4d8 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -216,7 +216,7 @@ jobs: if: ${{ steps.check-is-diff-non-empty.outputs.DIFF_IS_NON_EMPTY == '1' }} run: | mkdir outputs - echo "${{ matrix.language }} - ${{ matrix.type }}: https://github.com/${{ vars.DIFF_VIEW_USERNAME }}/${{ vars.DIFF_VIEW_REPO_NAME }}/compare/${{ steps.push.outputs.OLD_COMMIT_HASH }}..${{ steps.push.outputs.NEW_COMMIT_HASH }}" >> outputs/${{ matrix.type }}-${{ matrix.language }}.txt + echo "[${{ matrix.language }} - ${{ matrix.type }}](https://github.com/${{ vars.DIFF_VIEW_USERNAME }}/${{ vars.DIFF_VIEW_REPO_NAME }}/compare/${{ steps.push.outputs.OLD_COMMIT_HASH }}..${{ steps.push.outputs.NEW_COMMIT_HASH }})" >> outputs/${{ matrix.type }}-${{ matrix.language }}.txt - uses: actions/upload-artifact@v3 if: ${{ steps.check-is-diff-non-empty.outputs.DIFF_IS_NON_EMPTY == '1' }} From 0844fb19f2fd77714909a2ce30184a0d7c5fa0b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 7 Oct 2023 12:02:57 +0300 Subject: [PATCH 074/137] chore: change formatting --- .github/workflows/comment-diffs.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 6e950e4d8..357162d1e 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -216,7 +216,7 @@ jobs: if: ${{ steps.check-is-diff-non-empty.outputs.DIFF_IS_NON_EMPTY == '1' }} run: | mkdir outputs - echo "[${{ matrix.language }} - ${{ matrix.type }}](https://github.com/${{ vars.DIFF_VIEW_USERNAME }}/${{ vars.DIFF_VIEW_REPO_NAME }}/compare/${{ steps.push.outputs.OLD_COMMIT_HASH }}..${{ steps.push.outputs.NEW_COMMIT_HASH }})" >> outputs/${{ matrix.type }}-${{ matrix.language }}.txt + echo "- [${{ matrix.language }} ${{ matrix.type }}](https://github.com/${{ vars.DIFF_VIEW_USERNAME }}/${{ vars.DIFF_VIEW_REPO_NAME }}/compare/${{ steps.push.outputs.OLD_COMMIT_HASH }}..${{ steps.push.outputs.NEW_COMMIT_HASH }})" >> outputs/${{ matrix.type }}-${{ matrix.language }}.txt - uses: actions/upload-artifact@v3 if: ${{ steps.check-is-diff-non-empty.outputs.DIFF_IS_NON_EMPTY == '1' }} @@ -228,7 +228,6 @@ jobs: runs-on: ubuntu-latest needs: [comment-diffs] steps: - - uses: actions/checkout@v3 - name: Load outputs uses: actions/download-artifact@v3 with: @@ -257,16 +256,16 @@ jobs: github-token: ${{secrets.GITHUB_TOKEN}} script: | const replaceTable = { - "module-legacy": "**Native module**", - "module-mixed": "**Turbo module with backward compat**", - "module-new": "**Turbo module**", - "view-legacy": "**Native view**", - "view-mixed": "**Fabric view with backward compat**", - "view-new": "**Fabric view**", - "java-objc": "**Java and Objective C**", - "java-swift": "**Java and Swift**", - "kotlin-objc": "**Kotlin and Objective C**", - "kotlin-swift": "**Kotlin and Swift**" + "module-legacy": "Native module", + "module-mixed": "Turbo module with backward compat", + "module-new": "Turbo module", + "view-legacy": "Native view", + "view-mixed": "Fabric view with backward compat", + "view-new": "Fabric view", + "java-objc": "Java and Objective C", + "java-swift": "Java and Swift", + "kotlin-objc": "Kotlin and Objective C", + "kotlin-swift": "Kotlin and Swift" } const artifacts = `${{ steps.artifacts.outputs.ARTIFACTS }}`; @@ -276,6 +275,7 @@ jobs: }, artifacts) const body = `🤓☝️ This PR changes the output of \`create-react-native-library\`. You can find the diff of the changes below: + ${artifactsReplaced} `; From 004221a92ae9487fea72f4141754226c68a6675f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 7 Oct 2023 12:07:28 +0300 Subject: [PATCH 075/137] chore: change message --- .github/workflows/comment-diffs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 357162d1e..ab56994bc 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -274,7 +274,7 @@ jobs: return acc.replace(new RegExp(key, "g"), value); }, artifacts) - const body = `🤓☝️ This PR changes the output of \`create-react-native-library\`. You can find the diff of the changes below: + const body = `🤓☝️ This PR changes the output of \`create-react-native-library\`. You can find the diffs of affected templates below: ${artifactsReplaced} `; From 706850db0fd4a8266303d11f9f1128dc30f0580c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 7 Oct 2023 12:10:42 +0300 Subject: [PATCH 076/137] chore: more descriptive names --- .github/workflows/comment-diffs.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index ab56994bc..ba634b05b 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -10,7 +10,8 @@ on: - '!**.md' jobs: - comment-diffs: + generate-diffs-if-needed: + name: Generate library, compare, and post diffs if needed strategy: fail-fast: false matrix: @@ -224,9 +225,10 @@ jobs: name: outputs path: outputs/*.txt - read-values: + read-artifacts-and-comment: + name: Read the artifacts and comment runs-on: ubuntu-latest - needs: [comment-diffs] + needs: [generate-diffs-if-needed] steps: - name: Load outputs uses: actions/download-artifact@v3 From b950b674582643114f1f1bfbd49907e52d4ecaea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 7 Oct 2023 12:13:40 +0300 Subject: [PATCH 077/137] chore: use shorter names --- .github/workflows/comment-diffs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index ba634b05b..a186b5f55 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -1,4 +1,4 @@ -name: Comment diffs +name: Comment template diffs on: workflow_dispatch: pull_request: @@ -11,7 +11,7 @@ on: jobs: generate-diffs-if-needed: - name: Generate library, compare, and post diffs if needed + name: Generate diffs strategy: fail-fast: false matrix: From c3f3a184b27eef5661015b0e4934efe3f29424a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 7 Oct 2023 12:17:17 +0300 Subject: [PATCH 078/137] chore: fix typo --- .github/workflows/comment-diffs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index a186b5f55..fecc9e13d 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -276,7 +276,7 @@ jobs: return acc.replace(new RegExp(key, "g"), value); }, artifacts) - const body = `🤓☝️ This PR changes the output of \`create-react-native-library\`. You can find the diffs of affected templates below: + const body = `🤓☝️ This PR changes the output of \`create-react-native-library\`. You can find the diffs of effected templates below: ${artifactsReplaced} `; From a81b48f178a0dabfdcdb3f8ecc623a98073eb907 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 7 Oct 2023 12:18:06 +0300 Subject: [PATCH 079/137] chore: uncomment templates --- .github/workflows/comment-diffs.yml | 48 ++++++++++++++--------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index fecc9e13d..be3316058 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -17,33 +17,33 @@ jobs: matrix: type: - module-legacy - # - module-mixed - # - module-new + - module-mixed + - module-new - view-legacy - # - view-mixed - # - view-new + - view-mixed + - view-new language: - java-objc - # - java-swift - # - kotlin-objc - # - kotlin-swift - # exclude: - # - type: module-new - # language: java-swift - # - type: module-new - # language: kotlin-swift - # - type: module-mixed - # language: java-swift - # - type: module-mixed - # language: kotlin-swift - # - type: view-new - # language: java-swift - # - type: view-new - # language: kotlin-swift - # - type: view-mixed - # language: java-swift - # - type: view-mixed - # language: kotlin-swift + - java-swift + - kotlin-objc + - kotlin-swift + exclude: + - type: module-new + language: java-swift + - type: module-new + language: kotlin-swift + - type: module-mixed + language: java-swift + - type: module-mixed + language: kotlin-swift + - type: view-new + language: java-swift + - type: view-new + language: kotlin-swift + - type: view-mixed + language: java-swift + - type: view-mixed + language: kotlin-swift concurrency: group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.type }}-${{ matrix.language }} From 1b2c5b14eefe6823359bc71ce0ba9f7ac68f8389 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 14 Oct 2023 09:33:26 +0300 Subject: [PATCH 080/137] chore: use ubuntu --- .github/workflows/comment-diffs.yml | 58 +++++++++++++++-------------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index be3316058..fa43fa6e1 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -16,41 +16,41 @@ jobs: fail-fast: false matrix: type: - - module-legacy + # - module-legacy - module-mixed - - module-new - - view-legacy + # - module-new + # - view-legacy - view-mixed - - view-new + # - view-new language: - java-objc - - java-swift - - kotlin-objc - - kotlin-swift - exclude: - - type: module-new - language: java-swift - - type: module-new - language: kotlin-swift - - type: module-mixed - language: java-swift - - type: module-mixed - language: kotlin-swift - - type: view-new - language: java-swift - - type: view-new - language: kotlin-swift - - type: view-mixed - language: java-swift - - type: view-mixed - language: kotlin-swift + # - java-swift + # - kotlin-objc + # - kotlin-swift + # exclude: + # - type: module-new + # language: java-swift + # - type: module-new + # language: kotlin-swift + # - type: module-mixed + # language: java-swift + # - type: module-mixed + # language: kotlin-swift + # - type: view-new + # language: java-swift + # - type: view-new + # language: kotlin-swift + # - type: view-mixed + # language: java-swift + # - type: view-mixed + # language: kotlin-swift concurrency: group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.type }}-${{ matrix.language }} cancel-in-progress: true # TODO: use ubuntu once CLI is fixed - runs-on: macos-latest + runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v3 @@ -74,8 +74,9 @@ jobs: --type ${{ matrix.type }} \ --languages ${{ matrix.language }} \ --no-example \ - --no-local - + --no-local \ + --react-native-version 0.73.0-rc.2 + - name: Fetch main run: git fetch origin main @@ -103,7 +104,8 @@ jobs: --type ${{ matrix.type }} \ --languages ${{ matrix.language }} \ --no-example \ - --no-local + --no-local \ + --react-native-version 0.73.0-rc.2 - name: Set Diff view branch prefix env run: | From 5142fbc61eaecab1b29cdef26101d28768eb7944 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 14 Oct 2023 09:36:46 +0300 Subject: [PATCH 081/137] chore: add continue on errors to artifact fetching --- .github/workflows/comment-diffs.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index fa43fa6e1..1eecdf53d 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -234,6 +234,7 @@ jobs: steps: - name: Load outputs uses: actions/download-artifact@v3 + continue-on-error: true with: name: outputs path: outputs From ef93dd31aa43554bdd551ab1b51be4d304a800b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 14 Oct 2023 09:50:42 +0300 Subject: [PATCH 082/137] chore: add setup again --- .github/workflows/comment-diffs.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 1eecdf53d..97baf6dad 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -83,9 +83,8 @@ jobs: - name: Checkout main run: git checkout origin/main - # Removed this step for the sake of testing - # - name: Setup again # Add a check here to setup again if deps changed - # uses: ./.github/actions/setup + - name: Setup again # Add a check here to setup again if deps changed + uses: ./.github/actions/setup - name: Remove old build and build again run: | From f6ad6ada46ae280ff35ae79ef86761ab5b54d2a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 14 Oct 2023 10:53:15 +0300 Subject: [PATCH 083/137] chore: test config matrix --- .github/workflows/comment-diffs.yml | 47 ++++------------------------- .github/workflows/configMatrix.sh | 30 ++++++++++++++++++ 2 files changed, 36 insertions(+), 41 deletions(-) create mode 100644 .github/workflows/configMatrix.sh diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 97baf6dad..be2e34a48 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -12,44 +12,6 @@ on: jobs: generate-diffs-if-needed: name: Generate diffs - strategy: - fail-fast: false - matrix: - type: - # - module-legacy - - module-mixed - # - module-new - # - view-legacy - - view-mixed - # - view-new - language: - - java-objc - # - java-swift - # - kotlin-objc - # - kotlin-swift - # exclude: - # - type: module-new - # language: java-swift - # - type: module-new - # language: kotlin-swift - # - type: module-mixed - # language: java-swift - # - type: module-mixed - # language: kotlin-swift - # - type: view-new - # language: java-swift - # - type: view-new - # language: kotlin-swift - # - type: view-mixed - # language: java-swift - # - type: view-mixed - # language: kotlin-swift - - concurrency: - group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.type }}-${{ matrix.language }} - cancel-in-progress: true - - # TODO: use ubuntu once CLI is fixed runs-on: ubuntu-latest steps: - name: Checkout @@ -62,8 +24,11 @@ jobs: run: | yarn workspace create-react-native-library prepare - - name: Create library + - name: Create old version libraries run: | + source ./.github/workflows/configMatrix.sh + echo "$languages" + ./packages/create-react-native-library/bin/create-react-native-library new-version \ --slug @bob/react-native-test \ --description test \ @@ -83,8 +48,8 @@ jobs: - name: Checkout main run: git checkout origin/main - - name: Setup again # Add a check here to setup again if deps changed - uses: ./.github/actions/setup + # - name: Setup again # Add a check here to setup again if deps changed + # uses: ./.github/actions/setup - name: Remove old build and build again run: | diff --git a/.github/workflows/configMatrix.sh b/.github/workflows/configMatrix.sh new file mode 100644 index 000000000..378f7247a --- /dev/null +++ b/.github/workflows/configMatrix.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +# Source this file to set up the environment for the tests. + +export libraryTypes=( + module-legacy + module-mixed + module-new + view-legacy + view-mixed + view-new +) + +export languages=( + java-objc + java-swift + kotlin-objc + kotlin-swift +) + +export exclude=( + module-new/java-swift + module-new/kotlin-swift + module-mixed/java-swift + module-mixed/kotlin-swift + view-new/java-swift + view-new/kotlin-swift + view-mixed/java-swift + view-mixed/kotlin-swift +) From 53a6f8a59a4ea0184932965e40922db51ae199e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 14 Oct 2023 10:56:00 +0300 Subject: [PATCH 084/137] chore: test --- .github/workflows/comment-diffs.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index be2e34a48..2c07bb937 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -17,6 +17,12 @@ jobs: - name: Checkout uses: actions/checkout@v3 + - name: Test export + run: | + source ./.github/workflows/configMatrix.sh + echo "$languages" + exit -1 + - name: Setup uses: ./.github/actions/setup From 9410da1097644e1719361ecfa0b6340c0051223f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 14 Oct 2023 10:57:12 +0300 Subject: [PATCH 085/137] chore: try \ --- .github/workflows/configMatrix.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/configMatrix.sh b/.github/workflows/configMatrix.sh index 378f7247a..9cb8db7a4 100644 --- a/.github/workflows/configMatrix.sh +++ b/.github/workflows/configMatrix.sh @@ -11,11 +11,11 @@ export libraryTypes=( view-new ) -export languages=( - java-objc - java-swift - kotlin-objc - kotlin-swift +export languages=( \ + java-objc \ + java-swift \ + kotlin-objc \ + kotlin-swift \ ) export exclude=( From 8e654cd417a8157c5279a0885fcfa086e58d5566 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 14 Oct 2023 10:58:31 +0300 Subject: [PATCH 086/137] chore: try loop --- .github/workflows/comment-diffs.yml | 9 +++++++-- .github/workflows/configMatrix.sh | 10 +++++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 2c07bb937..3cdf1f59f 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -20,8 +20,13 @@ jobs: - name: Test export run: | source ./.github/workflows/configMatrix.sh - echo "$languages" - exit -1 + for libraryType in "${libraryTypes[@]}"; do + for language in "${languages[@]}"; do + if [[ ! "${exclude[*]}" =~ ${libraryType}/${language} ]]; then + echo "$libraryType" "$language" + fi + done + done - name: Setup uses: ./.github/actions/setup diff --git a/.github/workflows/configMatrix.sh b/.github/workflows/configMatrix.sh index 9cb8db7a4..f690f7dda 100644 --- a/.github/workflows/configMatrix.sh +++ b/.github/workflows/configMatrix.sh @@ -11,11 +11,11 @@ export libraryTypes=( view-new ) -export languages=( \ - java-objc \ - java-swift \ - kotlin-objc \ - kotlin-swift \ +export languages=( + java-objc + java-swift + kotlin-objc + kotlin-swift ) export exclude=( From 822a7b37584236950fa7205daf47df2fd00f7661 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 14 Oct 2023 11:11:06 +0300 Subject: [PATCH 087/137] chore: create libs --- .github/workflows/comment-diffs.yml | 116 +++++++++++++++++----------- 1 file changed, 69 insertions(+), 47 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 3cdf1f59f..c612277fc 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -17,17 +17,6 @@ jobs: - name: Checkout uses: actions/checkout@v3 - - name: Test export - run: | - source ./.github/workflows/configMatrix.sh - for libraryType in "${libraryTypes[@]}"; do - for language in "${languages[@]}"; do - if [[ ! "${exclude[*]}" =~ ${libraryType}/${language} ]]; then - echo "$libraryType" "$language" - fi - done - done - - name: Setup uses: ./.github/actions/setup @@ -37,21 +26,38 @@ jobs: - name: Create old version libraries run: | + # Source all the configuration values to load $languages, $types, and $exclude source ./.github/workflows/configMatrix.sh - echo "$languages" - - ./packages/create-react-native-library/bin/create-react-native-library new-version \ - --slug @bob/react-native-test \ - --description test \ - --author-name test \ - --author-email test@test \ - --author-url https://test.test \ - --repo-url https://test.test \ - --type ${{ matrix.type }} \ - --languages ${{ matrix.language }} \ - --no-example \ - --no-local \ - --react-native-version 0.73.0-rc.2 + + create_library() { + library_type=$1 + language=$2 + + echo "Generating $library_type/$language" + path_prefix="../test/$library_type/$language" + target_path="$path_prefix/new-version" + + npx create-react-native-library "$target_path" \ + --slug @bob/react-native-test \ + --description test \ + --author-name test \ + --author-email test@test \ + --author-url https://test.test \ + --repo-url https://test.test \ + --type "$library_type" \ + --languages "$language" \ + --no-example \ + --no-local \ + --react-native-version 0.73.0-rc.2 + } + + for library_type in "${libraryTypes[@]}"; do + for language in "${languages[@]}"; do + if [[ ! "${exclude[*]}" =~ ${library_type}/${language} ]]; then + create_library "$library_type" "$language" + fi + done + done - name: Fetch main run: git fetch origin main @@ -69,32 +75,48 @@ jobs: - name: Create library again run: | - ./packages/create-react-native-library/bin/create-react-native-library old-version \ - --slug @bob/react-native-test \ - --description test \ - --author-name test \ - --author-email test@test \ - --author-url https://test.test \ - --repo-url https://test.test \ - --type ${{ matrix.type }} \ - --languages ${{ matrix.language }} \ - --no-example \ - --no-local \ - --react-native-version 0.73.0-rc.2 - - - name: Set Diff view branch prefix env - run: | - BRANCH_PREFIX="${{ github.event.number }}-${{ matrix.type }}-${{ matrix.language }}" - echo "OLD_VERSION_BRANCH=$BRANCH_PREFIX-old-version" >> $GITHUB_ENV - echo "NEW_VERSION_BRANCH=$BRANCH_PREFIX-new-version" >> $GITHUB_ENV + # Source all the configuration values to load $languages, $types, and $exclude + source ./.github/workflows/configMatrix.sh - - uses: webfactory/ssh-agent@v0.7.0 - with: - ssh-private-key: ${{ secrets.SSH_DEPLOY_KEY }} + create_library() { + library_type=$1 + language=$2 + + echo "Running $library_type/$language" + path_prefix="../test/$library_type/$language" + target_path="$path_prefix/old-version" + + npx create-react-native-library "$target_path" \ + --slug @bob/react-native-test \ + --description test \ + --author-name test \ + --author-email test@test \ + --author-url https://test.test \ + --repo-url https://test.test \ + --type "$library_type" \ + --languages "$language" \ + --no-example \ + --no-local \ + --react-native-version 0.73.0-rc.2 + } + + for library_type in "${libraryTypes[@]}"; do + for language in "${languages[@]}"; do + if [[ ! "${exclude[*]}" =~ ${library_type}/${language} ]]; then + create_library "$library_type" "$language" + fi + done + done + + cd .. + echo "$PWD" + + # - uses: webfactory/ssh-agent@v0.7.0 + # with: + # ssh-private-key: ${{ secrets.SSH_DEPLOY_KEY }} - name: Create the Differ repo run: | - echo ${{ vars.DIFF_VIEW_SSH }} mkdir differ cd differ git init From a6ffcbf9bf961f70f0b5cdee234625737472100c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 14 Oct 2023 11:48:49 +0300 Subject: [PATCH 088/137] chore: add diff --- .github/workflows/comment-diffs.yml | 115 +++++++++++++++++++++++----- 1 file changed, 94 insertions(+), 21 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index c612277fc..ab7ae428f 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -17,6 +17,11 @@ jobs: - name: Checkout uses: actions/checkout@v3 + - name: Copy config matrix to persist it + run: | + mkdir ../configMatrix + cp ./.github/workflows/configMatrix.sh ../configMatrix/ + - name: Setup uses: ./.github/actions/setup @@ -27,7 +32,7 @@ jobs: - name: Create old version libraries run: | # Source all the configuration values to load $languages, $types, and $exclude - source ./.github/workflows/configMatrix.sh + source ../configMatrix/configMatrix.sh create_library() { library_type=$1 @@ -49,6 +54,9 @@ jobs: --no-example \ --no-local \ --react-native-version 0.73.0-rc.2 + + # Remove the .git folder of the created library + rm -rf "$target_path/.git" } for library_type in "${libraryTypes[@]}"; do @@ -58,12 +66,6 @@ jobs: fi done done - - - name: Fetch main - run: git fetch origin main - - - name: Checkout main - run: git checkout origin/main # - name: Setup again # Add a check here to setup again if deps changed # uses: ./.github/actions/setup @@ -76,7 +78,10 @@ jobs: - name: Create library again run: | # Source all the configuration values to load $languages, $types, and $exclude - source ./.github/workflows/configMatrix.sh + source ../configMatrix/configMatrix.sh + + git fetch origin main + git checkout origin/main create_library() { library_type=$1 @@ -98,6 +103,9 @@ jobs: --no-example \ --no-local \ --react-native-version 0.73.0-rc.2 + + # Remove the .git folder of the created library + rm -rf "$target_path/.git" } for library_type in "${libraryTypes[@]}"; do @@ -108,20 +116,9 @@ jobs: done done - cd .. - echo "$PWD" - - # - uses: webfactory/ssh-agent@v0.7.0 - # with: - # ssh-private-key: ${{ secrets.SSH_DEPLOY_KEY }} - - - name: Create the Differ repo + - name: Switch to diffs branch run: | - mkdir differ - cd differ - git init - git remote add origin ${{ vars.DIFF_VIEW_SSH }} - desired_branch="${{ env.NEW_VERSION_BRANCH }}" + desired_branch="diffs" # Check if the branch exists on the remote repository if git ls-remote --heads origin "$desired_branch" | grep -q "$desired_branch"; then echo "The branch $desired_branch already exists on the remote repository." @@ -132,6 +129,82 @@ jobs: git checkout -b "$desired_branch" # Create a new branch and switch to it fi + - name: Initiate diffs + run: | + # Source all the configuration values to load $languages, $types, and $exclude + source ../configMatrix/configMatrix.sh + + output_path="../output" + output_file="$output_path/output.txt" + + mkdir -p "$output_path" + + function copy_commit_diff(){ + library_type=$1 + language=$2 + + path_prefix="../test/$library_type/$language" + target_path_new_version="$path_prefix/new-version" + target_path_old_version="$path_prefix/old-version" + + # Remove everything except the .git folder + for i in $(ls | grep -v ".git") ; do rm -rf "$i"; done; + + # Copy the old version + cp -r "$target_path_old_version/." . + + git config --global user.email "text@test.com" + git config --global user.name "Github actions test" + + # Add all files and commit + git add -A || true && git commit -m "Automatic commit" || true + + # Remove everything except the .git folder + for i in $(ls | grep -v ".git") ; do rm -rf "$i"; done; + + # Copy the new version + cp -r "$target_path_new_version/." . + + # Add all files and commit + git add -A || true && git commit -m "Automatic commit" || true + + # echo diff + echo $(git diff HEAD~) + + # Check if there is a diff + if git diff --quiet HEAD~; then + echo "No diff" + else + # Push the branches + git push --set-upstream origin diffs + + # Get new version remote commit hash + new_version_commit_hash=$(git rev-parse --short origin/diffs) + + # Get old version remote commit hash + old_version_commit_hash=$(git rev-parse --short origin/diffs~) + + # Add output to file + echo "[$library_type/$language](https://github.com/${{github.repository}}/compare/$old_version_commit_hash..$new_version_commit_hash)" >> "$output_file" + + # Add empty line + echo \ >> $output_file + fi + } + + for library_type in "${libraryTypes[@]}"; do + for language in "${languages[@]}"; do + if [[ ! "${exclude[*]}" =~ ${library_type}/${language} ]]; then + copy_commit_diff "$library_type" "$language" + fi + done + done + + + # - uses: webfactory/ssh-agent@v0.7.0 + # with: + # ssh-private-key: ${{ secrets.SSH_DEPLOY_KEY }} + - name: Clean the Differ repo run: | cd differ From 268a1df507bbe9652396c6f1d62188267d57bb3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 14 Oct 2023 11:49:15 +0300 Subject: [PATCH 089/137] chore: change something --- .../templates/common-example/example/metro.config.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/create-react-native-library/templates/common-example/example/metro.config.js b/packages/create-react-native-library/templates/common-example/example/metro.config.js index b82321455..7b623337c 100644 --- a/packages/create-react-native-library/templates/common-example/example/metro.config.js +++ b/packages/create-react-native-library/templates/common-example/example/metro.config.js @@ -4,6 +4,7 @@ const escape = require('escape-string-regexp'); const exclusionList = require('metro-config/src/defaults/exclusionList'); const pak = require('../package.json'); +// Hi mom! const root = path.resolve(__dirname, '..'); const modules = Object.keys({ ...pak.peerDependencies }); From 1fe2aec4da235d5401996de962860f56bba198af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 14 Oct 2023 12:06:10 +0300 Subject: [PATCH 090/137] chore: use ssh key --- .github/workflows/comment-diffs.yml | 102 +++------------------------- 1 file changed, 11 insertions(+), 91 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index ab7ae428f..b218c1cc9 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -129,12 +129,17 @@ jobs: git checkout -b "$desired_branch" # Create a new branch and switch to it fi + - uses: webfactory/ssh-agent@v0.7.0 + with: + ssh-private-key: ${{ secrets.SSH_DEPLOY_KEY }} + - name: Initiate diffs + id: create-diffs run: | # Source all the configuration values to load $languages, $types, and $exclude source ../configMatrix/configMatrix.sh - output_path="../output" + output_path="../outputs" output_file="$output_path/output.txt" mkdir -p "$output_path" @@ -200,102 +205,17 @@ jobs: done done - - # - uses: webfactory/ssh-agent@v0.7.0 - # with: - # ssh-private-key: ${{ secrets.SSH_DEPLOY_KEY }} - - - name: Clean the Differ repo - run: | - cd differ - # Remove everything except the .git folder and it's contents. - for i in `ls | grep -v ".git"` ; do rm -rf $i; done; - - - name: Delete .git of new-version - run: | - rm -rf new-version/.git - - - name: Copy everything inside new-version to differ - run: | - cp -r new-version/* differ - - - name: Commit everything in differ - id: commit-new - run: | - git config --global user.email "text@test.com" - git config --global user.name "Github actions test" - cd differ - git add -A || true && git commit -m "Automatic commit" || true - - - name: Switch to old version repo - run: | - cd differ - desired_branch="${{ env.OLD_VERSION_BRANCH }}" - # Check if the branch exists on the remote repository - if git ls-remote --heads origin "$desired_branch" | grep -q "$desired_branch"; then - echo "The branch $desired_branch already exists on the remote repository." - git fetch origin "$desired_branch" # Fetch the branch from the remote - git checkout "$desired_branch" # Switch to the existing branch - else - echo "The branch $desired_branch does not exist on the remote repository." - git checkout -b "$desired_branch" # Create a new branch and switch to it - fi - - - name: Clean the Differ repo - run: | - cd differ - # Remove everything except the .git folder and it's contents. - for i in `ls | grep -v ".git"` ; do rm -rf $i; done; - - - name: Delete .git of old-version - run: | - rm -rf old-version/.git - - - name: Copy everything inside new-version to differ - run: | - cp -r old-version/* differ - - - name: Commit everything in differ - run: | - git config --global user.email "text@test.com" - git config --global user.name "Github actions test" - cd differ - git add -A || true && git commit -m "Automatic commit" || true - - - - name: Check if the diff is non-empty - id: check-is-diff-non-empty - run: | - cd differ - if git diff --quiet ${{ env.OLD_VERSION_BRANCH }}..${{ env.NEW_VERSION_BRANCH }}; then - result=0 # Diff is empty + if [ -s "$output_file" ]; then + echo "DIFF_IS_NON_EMPTY=1" >> $GITHUB_OUTPUT else - result=1 # Diff is not empty + echo "DIFF_IS_NON_EMPTY=0" >> $GITHUB_OUTPUT fi - echo "DIFF_IS_NON_EMPTY=$result" >> $GITHUB_OUTPUT - - - name: Push repos - if: ${{ steps.check-is-diff-non-empty.outputs.DIFF_IS_NON_EMPTY == '1' }} - id: push - run: | - cd differ - git push --set-upstream origin ${{ env.OLD_VERSION_BRANCH }} - echo "OLD_COMMIT_HASH=$(git rev-parse --short origin/${{ env.OLD_VERSION_BRANCH }})" >> $GITHUB_OUTPUT - git checkout ${{ env.NEW_VERSION_BRANCH }} - git push --set-upstream origin ${{ env.NEW_VERSION_BRANCH }} - echo "NEW_COMMIT_HASH=$(git rev-parse --short origin/${{ env.NEW_VERSION_BRANCH }})" >> $GITHUB_OUTPUT - - - name: Write changes to common file - if: ${{ steps.check-is-diff-non-empty.outputs.DIFF_IS_NON_EMPTY == '1' }} - run: | - mkdir outputs - echo "- [${{ matrix.language }} ${{ matrix.type }}](https://github.com/${{ vars.DIFF_VIEW_USERNAME }}/${{ vars.DIFF_VIEW_REPO_NAME }}/compare/${{ steps.push.outputs.OLD_COMMIT_HASH }}..${{ steps.push.outputs.NEW_COMMIT_HASH }})" >> outputs/${{ matrix.type }}-${{ matrix.language }}.txt - uses: actions/upload-artifact@v3 - if: ${{ steps.check-is-diff-non-empty.outputs.DIFF_IS_NON_EMPTY == '1' }} + if: ${{ steps.create-diffs.outputs.DIFF_IS_NON_EMPTY == '1' }} with: name: outputs - path: outputs/*.txt + path: ../outputs/*.txt read-artifacts-and-comment: name: Read the artifacts and comment From a8d263cdefa2f20282c9ccd1588dbe89af955f47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 14 Oct 2023 12:31:51 +0300 Subject: [PATCH 091/137] chore: remove secret --- .github/workflows/comment-diffs.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index b218c1cc9..9d80dd023 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -129,10 +129,6 @@ jobs: git checkout -b "$desired_branch" # Create a new branch and switch to it fi - - uses: webfactory/ssh-agent@v0.7.0 - with: - ssh-private-key: ${{ secrets.SSH_DEPLOY_KEY }} - - name: Initiate diffs id: create-diffs run: | From 970946679546aeb8c95658b5d5316b8940384ae1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 14 Oct 2023 12:38:06 +0300 Subject: [PATCH 092/137] chore: add write all permission --- .github/workflows/comment-diffs.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 9d80dd023..f267a1aac 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -8,6 +8,7 @@ on: - '.github/workflows/comment-diffs.yml' - 'packages/create-react-native-library/**' - '!**.md' +permissions: write-all jobs: generate-diffs-if-needed: From 7d822c4256ed998246daf78184c80d6da3e5f02c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 14 Oct 2023 12:49:57 +0300 Subject: [PATCH 093/137] chore: write diffs --- .github/workflows/comment-diffs.yml | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index f267a1aac..ce3652e1b 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -178,16 +178,27 @@ jobs: echo "No diff" else # Push the branches - git push --set-upstream origin diffs + # git push --set-upstream origin diffs # Get new version remote commit hash - new_version_commit_hash=$(git rev-parse --short origin/diffs) + # new_version_commit_hash=$(git rev-parse --short origin/diffs) # Get old version remote commit hash - old_version_commit_hash=$(git rev-parse --short origin/diffs~) + # old_version_commit_hash=$(git rev-parse --short origin/diffs~) # Add output to file - echo "[$library_type/$language](https://github.com/${{github.repository}}/compare/$old_version_commit_hash..$new_version_commit_hash)" >> "$output_file" + # echo "[$library_type/$language](https://github.com/${{github.repository}}/compare/$old_version_commit_hash..$new_version_commit_hash)" >> "$output_file" + + + # Add type to output file + message="""
+ ${library_type}/${language}""" + echo """${message}""" >> $output_file + + # Add changes to output file + git diff HEAD~ >> $output_file + + echo "
" >> $output_file # Add empty line echo \ >> $output_file @@ -203,6 +214,7 @@ jobs: done if [ -s "$output_file" ]; then + cat $output_file echo "DIFF_IS_NON_EMPTY=1" >> $GITHUB_OUTPUT else echo "DIFF_IS_NON_EMPTY=0" >> $GITHUB_OUTPUT From f4659e765c598fa59632cb34e028ce6e18b2c2ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 14 Oct 2023 12:55:55 +0300 Subject: [PATCH 094/137] chore: outputs --- .github/workflows/comment-diffs.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index ce3652e1b..e961d5b97 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -220,11 +220,17 @@ jobs: echo "DIFF_IS_NON_EMPTY=0" >> $GITHUB_OUTPUT fi + # Remove outputs if it exists + rm -rf ./outputs || true + + # Copy the outputs to cwd + cp -r $output_path ./outputs + - uses: actions/upload-artifact@v3 if: ${{ steps.create-diffs.outputs.DIFF_IS_NON_EMPTY == '1' }} with: name: outputs - path: ../outputs/*.txt + path: outputs/*.txt read-artifacts-and-comment: name: Read the artifacts and comment From 6e047d13a2bef0ddd200e621f0174a05041a9e29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 14 Oct 2023 13:09:07 +0300 Subject: [PATCH 095/137] chore: testing --- .github/workflows/comment-diffs.yml | 36 ++++++----------------------- 1 file changed, 7 insertions(+), 29 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index e961d5b97..76192aa01 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -117,18 +117,13 @@ jobs: done done - - name: Switch to diffs branch + - name: Remove everything + run: rm -rf * + + - name: Checkout + # uses: checkout run: | - desired_branch="diffs" - # Check if the branch exists on the remote repository - if git ls-remote --heads origin "$desired_branch" | grep -q "$desired_branch"; then - echo "The branch $desired_branch already exists on the remote repository." - git fetch origin "$desired_branch" # Fetch the branch from the remote - git checkout "$desired_branch" # Switch to the existing branch - else - echo "The branch $desired_branch does not exist on the remote repository." - git checkout -b "$desired_branch" # Create a new branch and switch to it - fi + git init - name: Initiate diffs id: create-diffs @@ -265,28 +260,11 @@ jobs: with: github-token: ${{secrets.GITHUB_TOKEN}} script: | - const replaceTable = { - "module-legacy": "Native module", - "module-mixed": "Turbo module with backward compat", - "module-new": "Turbo module", - "view-legacy": "Native view", - "view-mixed": "Fabric view with backward compat", - "view-new": "Fabric view", - "java-objc": "Java and Objective C", - "java-swift": "Java and Swift", - "kotlin-objc": "Kotlin and Objective C", - "kotlin-swift": "Kotlin and Swift" - } - const artifacts = `${{ steps.artifacts.outputs.ARTIFACTS }}`; - const artifactsReplaced = Object.entries(replaceTable).reduce((acc, [key, value]) => { - return acc.replace(new RegExp(key, "g"), value); - }, artifacts) - const body = `🤓☝️ This PR changes the output of \`create-react-native-library\`. You can find the diffs of effected templates below: - ${artifactsReplaced} + ${artifacts} `; const comments = await github.issues.listComments({ From cc7e3c4dcef18281101bf0e921702c29a46841f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 14 Oct 2023 13:11:19 +0300 Subject: [PATCH 096/137] chore: force install --- .github/workflows/comment-diffs.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 76192aa01..86c6d4292 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -23,8 +23,14 @@ jobs: mkdir ../configMatrix cp ./.github/workflows/configMatrix.sh ../configMatrix/ - - name: Setup - uses: ./.github/actions/setup + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version-file: .nvmrc + + - name: Install dependencies + run: yarn install --immutable + shell: bash - name: Build crnl run: | From 8e8ee8935dc62260bfa29b2f6232f87ef5474220 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 14 Oct 2023 13:16:57 +0300 Subject: [PATCH 097/137] chore: change remove --- .github/workflows/comment-diffs.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 86c6d4292..7f49c9dfe 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -124,7 +124,7 @@ jobs: done - name: Remove everything - run: rm -rf * + run: rm -rf ./* - name: Checkout # uses: checkout @@ -142,6 +142,9 @@ jobs: mkdir -p "$output_path" + git config --global user.email "text@test.com" + git config --global user.name "Github actions test" + function copy_commit_diff(){ library_type=$1 language=$2 @@ -156,9 +159,6 @@ jobs: # Copy the old version cp -r "$target_path_old_version/." . - git config --global user.email "text@test.com" - git config --global user.name "Github actions test" - # Add all files and commit git add -A || true && git commit -m "Automatic commit" || true From 9c5f810cca48315c4e60c0356c8220e1682d9949 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 14 Oct 2023 16:08:36 +0300 Subject: [PATCH 098/137] chore: remove everything --- .github/workflows/comment-diffs.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 7f49c9dfe..1056add77 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -124,7 +124,10 @@ jobs: done - name: Remove everything - run: rm -rf ./* + run: | + # Remove everything except the .git folder + for i in $(ls | grep -v ".git") ; do rm -rf "$i"; done; + rm -rf ./.git - name: Checkout # uses: checkout From 57b1bf9fe9ab8f56b0db806ab3445c446c6c2fb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 14 Oct 2023 16:13:46 +0300 Subject: [PATCH 099/137] chore: comment some library types --- .github/workflows/configMatrix.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/configMatrix.sh b/.github/workflows/configMatrix.sh index f690f7dda..451c38f27 100644 --- a/.github/workflows/configMatrix.sh +++ b/.github/workflows/configMatrix.sh @@ -4,18 +4,18 @@ export libraryTypes=( module-legacy - module-mixed - module-new - view-legacy - view-mixed - view-new + # module-mixed + # module-new + # view-legacy + # view-mixed + # view-new ) export languages=( java-objc - java-swift - kotlin-objc - kotlin-swift + # java-swift + # kotlin-objc + # kotlin-swift ) export exclude=( From 385dda1c9dfecebecaa7284bcb63eef424e6cfbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 14 Oct 2023 16:18:12 +0300 Subject: [PATCH 100/137] chore: return if commit fails --- .github/workflows/comment-diffs.yml | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 1056add77..c93832d3d 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -163,7 +163,14 @@ jobs: cp -r "$target_path_old_version/." . # Add all files and commit - git add -A || true && git commit -m "Automatic commit" || true + git add -A || true + + if git commit -m "Automatic commit"; then + echo "Commit successful" + else + echo "No changes" + return + fi # Remove everything except the .git folder for i in $(ls | grep -v ".git") ; do rm -rf "$i"; done; @@ -172,7 +179,14 @@ jobs: cp -r "$target_path_new_version/." . # Add all files and commit - git add -A || true && git commit -m "Automatic commit" || true + git add -A || true + + if git commit -m "Automatic commit"; then + echo "Commit successful" + else + echo "No changes" + return + fi # echo diff echo $(git diff HEAD~) From 31b5c8879ebd76a00f2cdf1f07a1cf211ae31dd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 14 Oct 2023 16:22:02 +0300 Subject: [PATCH 101/137] chore: add diff view --- .github/workflows/comment-diffs.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index c93832d3d..f4056f033 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -211,7 +211,9 @@ jobs: # Add type to output file message="""
${library_type}/${language}""" - echo """${message}""" >> $output_file + echo """```diff + ${message} + ```""" >> $output_file # Add changes to output file git diff HEAD~ >> $output_file From 6b2d77c80734253e2f62173f8095d27396e9ee6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 14 Oct 2023 16:26:06 +0300 Subject: [PATCH 102/137] chore: test --- .github/workflows/comment-diffs.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index f4056f033..feb4b0e3f 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -211,9 +211,10 @@ jobs: # Add type to output file message="""
${library_type}/${language}""" - echo """```diff - ${message} - ```""" >> $output_file + + echo "```diff" >> $output_file + echo """${message}""" >> $output_file + echo "```" >> $output_file # Add changes to output file git diff HEAD~ >> $output_file From 43d7dc7d3538cbc43c15a82707f34ea3f49e04be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 14 Oct 2023 16:27:02 +0300 Subject: [PATCH 103/137] chore: add git pull --- .github/workflows/comment-diffs.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index feb4b0e3f..54c412606 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -89,6 +89,7 @@ jobs: git fetch origin main git checkout origin/main + git pull || true create_library() { library_type=$1 From beb4b3ef13c05bfdc17063b852a403cbcc39963a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 14 Oct 2023 16:30:25 +0300 Subject: [PATCH 104/137] chore: add \ --- .github/workflows/comment-diffs.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 54c412606..6761691c6 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -213,9 +213,11 @@ jobs: message="""
${library_type}/${language}""" - echo "```diff" >> $output_file + echo $message >> $output_file + + echo "\`\`\`diff" >> $output_file echo """${message}""" >> $output_file - echo "```" >> $output_file + echo "\`\`\`" >> $output_file # Add changes to output file git diff HEAD~ >> $output_file From 8769d41a0569675cc3a642b70560546e39ac7f72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 14 Oct 2023 16:36:45 +0300 Subject: [PATCH 105/137] chore: use different install --- .github/actions/setup/action.yml | 134 ++++++++++++++++++++++++---- .github/workflows/comment-diffs.yml | 8 +- 2 files changed, 121 insertions(+), 21 deletions(-) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index e26611925..2b00b529e 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -1,27 +1,125 @@ -name: Setup -description: Setup Node.js and install dependencies +# https://gist.github.com/belgattitude/042f9caf10d029badbde6cf9d43e400a + +######################################################################################## +# "yarn install" composite action for yarn 3/4+ and "nodeLinker: node-modules" # +#--------------------------------------------------------------------------------------# +# Requirement: @setup/node should be run before # +# # +# Usage in workflows steps: # +# # +# - name: 📥 Monorepo install # +# uses: ./.github/actions/yarn-nm-install # +# with: # +# enable-corepack: false # (default = 'false') # +# cwd: ${{ github.workspace }}/apps/my-app # (default = '.') # +# cache-prefix: add cache key prefix # (default = 'default') # +# cache-node-modules: false # (default = 'false') # +# cache-install-state: false # (default = 'false') # +# # +# Reference: # +# - latest: https://gist.github.com/belgattitude/042f9caf10d029badbde6cf9d43e400a # +# # +# Versions: # +# - 1.1.0 - 22-07-2023 - Option to enable npm global cache folder. # +# - 1.0.4 - 15-07-2023 - Fix corepack was always enabled. # +# - 1.0.3 - 05-07-2023 - YARN_ENABLE_MIRROR to false (speed up cold start) # +# - 1.0.2 - 02-06-2023 - install-state default to false # +# - 1.0.1 - 29-05-2023 - cache-prefix doc # +# - 1.0.0 - 27-05-2023 - new input: cache-prefix # +######################################################################################## + +name: 'Monorepo install (yarn)' +description: 'Run yarn install with node_modules linker and cache enabled' +inputs: + cwd: + description: "Changes node's process.cwd() if the project is not located on the root. Default to process.cwd()" + required: false + default: '.' + cache-prefix: + description: 'Add a specific cache-prefix' + required: false + default: 'default' + cache-npm-cache: + description: 'Cache npm global cache folder often used by node-gyp, prebuild binaries (invalidated on lock/os/node-version)' + required: false + default: 'true' + cache-node-modules: + description: 'Cache node_modules, might speed up link step (invalidated lock/os/node-version/branch)' + required: false + default: 'false' + cache-install-state: + description: 'Cache yarn install state, might speed up resolution step when node-modules cache is activated (invalidated lock/os/node-version/branch)' + required: false + default: 'false' + enable-corepack: + description: 'Enable corepack' + required: false + default: 'true' runs: - using: composite + using: 'composite' + steps: - - name: Setup Node.js - uses: actions/setup-node@v3 - with: - node-version-file: .nvmrc + - name: ⚙️ Enable Corepack + if: inputs.enable-corepack == 'true' + shell: bash + working-directory: ${{ inputs.cwd }} + run: corepack enable + + - name: ⚙️ Expose yarn config as "$GITHUB_OUTPUT" + id: yarn-config + shell: bash + working-directory: ${{ inputs.cwd }} + env: + YARN_ENABLE_GLOBAL_CACHE: 'false' + run: | + echo "CACHE_FOLDER=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT + echo "CURRENT_NODE_VERSION="node-$(node --version)"" >> $GITHUB_OUTPUT + echo "CURRENT_BRANCH=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's,/,-,g')" >> $GITHUB_OUTPUT + echo "NPM_GLOBAL_CACHE_FOLDER=$(npm config get cache)" >> $GITHUB_OUTPUT - - name: Cache dependencies - id: yarn-cache + - name: ♻️ Restore yarn cache uses: actions/cache@v3 + id: yarn-download-cache with: - path: | - **/node_modules - .yarn/install-state.gz - key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('**/package.json') }} + path: ${{ steps.yarn-config.outputs.CACHE_FOLDER }} + key: yarn-download-cache-${{ inputs.cache-prefix }}-${{ hashFiles(format('{0}/yarn.lock', inputs.cwd), format('{0}/.yarnrc.yml', inputs.cwd)) }} restore-keys: | - ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} - ${{ runner.os }}-yarn- + yarn-download-cache-${{ inputs.cache-prefix }}- + + - name: ♻️ Restore node_modules + if: inputs.cache-node-modules == 'true' + id: yarn-nm-cache + uses: actions/cache@v3 + with: + path: ${{ inputs.cwd }}/**/node_modules + key: yarn-nm-cache-${{ inputs.cache-prefix }}-${{ runner.os }}-${{ steps.yarn-config.outputs.CURRENT_NODE_VERSION }}-${{ steps.yarn-config.outputs.CURRENT_BRANCH }}-${{ hashFiles(format('{0}/yarn.lock', inputs.cwd), format('{0}/.yarnrc.yml', inputs.cwd)) }} + + - name: ♻️ Restore global npm cache folder + if: inputs.cache-npm-cache == 'true' + id: npm-global-cache + uses: actions/cache@v3 + with: + path: ${{ steps.yarn-config.outputs.NPM_GLOBAL_CACHE_FOLDER }} + key: npm-global-cache-${{ inputs.cache-prefix }}-${{ runner.os }}-${{ steps.yarn-config.outputs.CURRENT_NODE_VERSION }}-${{ hashFiles(format('{0}/yarn.lock', inputs.cwd), format('{0}/.yarnrc.yml', inputs.cwd)) }} + + - name: ♻️ Restore yarn install state + if: inputs.cache-install-state == 'true' && inputs.cache-node-modules == 'true' + id: yarn-install-state-cache + uses: actions/cache@v3 + with: + path: ${{ inputs.cwd }}/.yarn/ci-cache + key: yarn-install-state-cache-${{ inputs.cache-prefix }}-${{ runner.os }}-${{ steps.yarn-config.outputs.CURRENT_NODE_VERSION }}-${{ steps.yarn-config.outputs.CURRENT_BRANCH }}-${{ hashFiles(format('{0}/yarn.lock', inputs.cwd), format('{0}/.yarnrc.yml', inputs.cwd)) }} - - name: Install dependencies - if: steps.yarn-cache.outputs.cache-hit != 'true' - run: yarn install --immutable + - name: 📥 Install dependencies shell: bash + working-directory: ${{ inputs.cwd }} + run: yarn install --immutable --inline-builds + env: + # Overrides/align yarnrc.yml options (v3, v4) for a CI context + YARN_ENABLE_GLOBAL_CACHE: 'false' # Use local cache folder to keep downloaded archives + YARN_ENABLE_MIRROR: 'false' # Prevent populating global cache for caches misses (local cache only) + YARN_NM_MODE: 'hardlinks-local' # Reduce node_modules size + YARN_INSTALL_STATE_PATH: '.yarn/ci-cache/install-state.gz' # Might speed up resolution step when node_modules present + # Other environment variables + HUSKY: '0' # By default do not run HUSKY install diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 6761691c6..b31e254c4 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -28,9 +28,11 @@ jobs: with: node-version-file: .nvmrc - - name: Install dependencies - run: yarn install --immutable - shell: bash + - name: 📥 Monorepo install + uses: ./.github/actions/setup + with: + cache-node-modules: true + cache-install-state: true - name: Build crnl run: | From 2caa6851ccd3951126a9908aee1596eeb83db773 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 14 Oct 2023 16:40:19 +0300 Subject: [PATCH 106/137] chore: let everything run --- .github/workflows/comment-diffs.yml | 1 + .github/workflows/configMatrix.sh | 16 ++++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index b31e254c4..fc03737f6 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -31,6 +31,7 @@ jobs: - name: 📥 Monorepo install uses: ./.github/actions/setup with: + enable-corepack: false cache-node-modules: true cache-install-state: true diff --git a/.github/workflows/configMatrix.sh b/.github/workflows/configMatrix.sh index 451c38f27..f690f7dda 100644 --- a/.github/workflows/configMatrix.sh +++ b/.github/workflows/configMatrix.sh @@ -4,18 +4,18 @@ export libraryTypes=( module-legacy - # module-mixed - # module-new - # view-legacy - # view-mixed - # view-new + module-mixed + module-new + view-legacy + view-mixed + view-new ) export languages=( java-objc - # java-swift - # kotlin-objc - # kotlin-swift + java-swift + kotlin-objc + kotlin-swift ) export exclude=( From 2f25705d91844ece1abe9d0363238e511d5d5f1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 14 Oct 2023 17:07:14 +0300 Subject: [PATCH 107/137] chore: parse --- .github/workflows/comment-diffs.yml | 58 ++++++++++++++++++++--------- 1 file changed, 41 insertions(+), 17 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index fc03737f6..52a540b28 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -212,23 +212,14 @@ jobs: # echo "[$library_type/$language](https://github.com/${{github.repository}}/compare/$old_version_commit_hash..$new_version_commit_hash)" >> "$output_file" - # Add type to output file - message="""
- ${library_type}/${language}""" + # Add type to output file + echo "${library_type} ${language}" >> $output_file - echo $message >> $output_file + # Add changes to output file + git diff HEAD~ >> $output_file - echo "\`\`\`diff" >> $output_file - echo """${message}""" >> $output_file - echo "\`\`\`" >> $output_file - - # Add changes to output file - git diff HEAD~ >> $output_file - - echo "
" >> $output_file - - # Add empty line - echo \ >> $output_file + # Add empty line + echo \ >> $output_file fi } @@ -292,11 +283,44 @@ jobs: with: github-token: ${{secrets.GITHUB_TOKEN}} script: | + const replaceTable = { + "module-legacy": "Native module", + "module-mixed": "Turbo module with backward compat", + "module-new": "Turbo module", + "view-legacy": "Native view", + "view-mixed": "Fabric view with backward compat", + "view-new": "Fabric view", + "java-objc": "Java and Objective C", + "java-swift": "Java and Swift", + "kotlin-objc": "Kotlin and Objective C", + "kotlin-swift": "Kotlin and Swift" + } + const artifacts = `${{ steps.artifacts.outputs.ARTIFACTS }}`; + // Get every input by empty line + + const splittedArtifacts = artifacts.split("\n\n") + const parsedArtifacts = splittedArtifacts.map((artifact) => { + // The first line indicates the type + const type = artifacts.split("\n").shift() + const typeReplaced = Object.entries(replaceTable).reduce((acc, [key, value]) => { + return acc.replace(new RegExp(key, "g"), value); + }, type) + + return `
+ ${typeReplaced} + \`\`\`diff + ${artifact} + \`\`\` +
+ + ` + }) + const body = `🤓☝️ This PR changes the output of \`create-react-native-library\`. You can find the diffs of effected templates below: - ${artifacts} + ${parsedArtifacts} `; const comments = await github.issues.listComments({ @@ -313,4 +337,4 @@ jobs: repo: context.repo.repo, body }) - + From 5a04c9b9841b10bf20f4bc2ed8ffd0f19c4926a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 14 Oct 2023 17:13:03 +0300 Subject: [PATCH 108/137] chore: fix indenting --- .github/workflows/comment-diffs.yml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 52a540b28..f7c736be2 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -308,14 +308,7 @@ jobs: return acc.replace(new RegExp(key, "g"), value); }, type) - return `
- ${typeReplaced} - \`\`\`diff - ${artifact} - \`\`\` -
- - ` + return `
${typeReplaced}\n\`\`\`diff\n${artifact}\n\`\`\`\n\n
\n\n`; }) const body = `🤓☝️ This PR changes the output of \`create-react-native-library\`. You can find the diffs of effected templates below: From 28750f102e60d477c0c20a3740bb2af1bf5bc247 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 14 Oct 2023 17:47:19 +0300 Subject: [PATCH 109/137] chore: format --- .github/workflows/comment-diffs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index f7c736be2..aef026971 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -308,7 +308,7 @@ jobs: return acc.replace(new RegExp(key, "g"), value); }, type) - return `
${typeReplaced}\n\`\`\`diff\n${artifact}\n\`\`\`\n\n
\n\n`; + return `
${typeReplaced}\n\n\`\`\`diff\n${artifact}\n\`\`\`\n
\n\n`; }) const body = `🤓☝️ This PR changes the output of \`create-react-native-library\`. You can find the diffs of effected templates below: From 6227760705932c4a01e5e5326313876aab4c9b23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 14 Oct 2023 18:05:45 +0300 Subject: [PATCH 110/137] chore: write cwd --- .github/workflows/comment-diffs.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index aef026971..1dc7eca00 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -267,10 +267,6 @@ jobs: run: | if ls outputs/*.txt; then result=1 # Artifacts are not empty - echo "ARTIFACTS<> $GITHUB_OUTPUT - cat outputs/*.txt >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT - else result=0 # Artifacts are empty fi @@ -283,6 +279,12 @@ jobs: with: github-token: ${{secrets.GITHUB_TOKEN}} script: | + const fs = require('fs'); + + fs.readdirSync('./outputs').forEach(file => { + console.log(file); + }); + const replaceTable = { "module-legacy": "Native module", "module-mixed": "Turbo module with backward compat", From 09937ad1d0a88b87b007101fb34c87aa7dbb1a27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 14 Oct 2023 18:14:05 +0300 Subject: [PATCH 111/137] chore: tsetingg --- .github/workflows/comment-diffs.yml | 30 ++++++++--------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 1dc7eca00..bae0ea9e8 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -145,7 +145,6 @@ jobs: source ../configMatrix/configMatrix.sh output_path="../outputs" - output_file="$output_path/output.txt" mkdir -p "$output_path" @@ -155,6 +154,7 @@ jobs: function copy_commit_diff(){ library_type=$1 language=$2 + output_file="$output_path/$library_type-$language.txt" path_prefix="../test/$library_type/$language" target_path_new_version="$path_prefix/new-version" @@ -211,15 +211,8 @@ jobs: # Add output to file # echo "[$library_type/$language](https://github.com/${{github.repository}}/compare/$old_version_commit_hash..$new_version_commit_hash)" >> "$output_file" - - # Add type to output file - echo "${library_type} ${language}" >> $output_file - # Add changes to output file git diff HEAD~ >> $output_file - - # Add empty line - echo \ >> $output_file fi } @@ -281,10 +274,6 @@ jobs: script: | const fs = require('fs'); - fs.readdirSync('./outputs').forEach(file => { - console.log(file); - }); - const replaceTable = { "module-legacy": "Native module", "module-mixed": "Turbo module with backward compat", @@ -298,19 +287,16 @@ jobs: "kotlin-swift": "Kotlin and Swift" } - const artifacts = `${{ steps.artifacts.outputs.ARTIFACTS }}`; - - // Get every input by empty line + const parsedArtifacts = fs.readdirSync('./outputs').map(fileName => { + const [type, language] = fileName.split("-"); - const splittedArtifacts = artifacts.split("\n\n") - const parsedArtifacts = splittedArtifacts.map((artifact) => { - // The first line indicates the type - const type = artifacts.split("\n").shift() - const typeReplaced = Object.entries(replaceTable).reduce((acc, [key, value]) => { + const header = Object.entries(replaceTable).reduce((acc, [key, value]) => { return acc.replace(new RegExp(key, "g"), value); - }, type) + }, `${type} ${language}`); + + const fileContents = fs.readFileSync(`./outputs/${fileName}`, 'utf8'); - return `
${typeReplaced}\n\n\`\`\`diff\n${artifact}\n\`\`\`\n
\n\n`; + return `
${header}\n\n\`\`\`diff\n${fileContents}\n\`\`\`\n
\n\n`; }) const body = `🤓☝️ This PR changes the output of \`create-react-native-library\`. You can find the diffs of effected templates below: From dc467187d5c0ac62d91d133a3edf6d60b6e0e519 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 14 Oct 2023 18:17:56 +0300 Subject: [PATCH 112/137] chore: fix indenting --- .github/workflows/comment-diffs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index bae0ea9e8..b876033b4 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -211,8 +211,8 @@ jobs: # Add output to file # echo "[$library_type/$language](https://github.com/${{github.repository}}/compare/$old_version_commit_hash..$new_version_commit_hash)" >> "$output_file" - # Add changes to output file - git diff HEAD~ >> $output_file + # Add changes to output file + git diff HEAD~ >> $output_file fi } From 6647039558b3d4257204f6f5cebe4f98ede35a12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 14 Oct 2023 18:20:48 +0300 Subject: [PATCH 113/137] chore: change stuff --- .github/workflows/comment-diffs.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index b876033b4..239fdee55 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -224,8 +224,7 @@ jobs: done done - if [ -s "$output_file" ]; then - cat $output_file + if ls outputs/*.txt; then echo "DIFF_IS_NON_EMPTY=1" >> $GITHUB_OUTPUT else echo "DIFF_IS_NON_EMPTY=0" >> $GITHUB_OUTPUT From e2a0ece928abc45cc6406f96fc76cf023110b9b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 14 Oct 2023 18:23:48 +0300 Subject: [PATCH 114/137] chore: fix --- .github/workflows/comment-diffs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 239fdee55..d988ba78d 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -224,7 +224,7 @@ jobs: done done - if ls outputs/*.txt; then + if ls "$output_path/*.txt"; then echo "DIFF_IS_NON_EMPTY=1" >> $GITHUB_OUTPUT else echo "DIFF_IS_NON_EMPTY=0" >> $GITHUB_OUTPUT From a7f737a3237e7726093010edc01729eff7fedacb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 14 Oct 2023 18:30:21 +0300 Subject: [PATCH 115/137] chore: debug --- .github/workflows/comment-diffs.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index d988ba78d..9497902e9 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -154,6 +154,7 @@ jobs: function copy_commit_diff(){ library_type=$1 language=$2 + output_file="$output_path/$library_type-$language.txt" path_prefix="../test/$library_type/$language" @@ -213,6 +214,7 @@ jobs: # Add changes to output file git diff HEAD~ >> $output_file + echo "$output_file" fi } From feb1ecb342118a82bbc732d7fb3ac0e91b529c71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 14 Oct 2023 18:32:11 +0300 Subject: [PATCH 116/137] chore: quiet --- .github/workflows/comment-diffs.yml | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 9497902e9..419219f62 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -170,7 +170,7 @@ jobs: # Add all files and commit git add -A || true - if git commit -m "Automatic commit"; then + if git commit -qm "Automatic commit"; then echo "Commit successful" else echo "No changes" @@ -186,16 +186,13 @@ jobs: # Add all files and commit git add -A || true - if git commit -m "Automatic commit"; then - echo "Commit successful" + if git commit -qm "Automatic commit"; then + echo "Commit successful" else - echo "No changes" - return + echo "No changes" + return fi - # echo diff - echo $(git diff HEAD~) - # Check if there is a diff if git diff --quiet HEAD~; then echo "No diff" @@ -213,6 +210,8 @@ jobs: # echo "[$library_type/$language](https://github.com/${{github.repository}}/compare/$old_version_commit_hash..$new_version_commit_hash)" >> "$output_file" # Add changes to output file + echo $(git diff HEAD~) + git diff HEAD~ >> $output_file echo "$output_file" fi From efcb3c230e16cac181362dc56eeeab133ab0be44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 14 Oct 2023 18:36:52 +0300 Subject: [PATCH 117/137] chore: use + --- .github/workflows/comment-diffs.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 419219f62..4d172831f 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -155,7 +155,7 @@ jobs: library_type=$1 language=$2 - output_file="$output_path/$library_type-$language.txt" + output_file="$output_path/$library_type+$language.txt" path_prefix="../test/$library_type/$language" target_path_new_version="$path_prefix/new-version" @@ -208,12 +208,10 @@ jobs: # Add output to file # echo "[$library_type/$language](https://github.com/${{github.repository}}/compare/$old_version_commit_hash..$new_version_commit_hash)" >> "$output_file" - - # Add changes to output file - echo $(git diff HEAD~) - git diff HEAD~ >> $output_file echo "$output_file" + + cat "$output_file" fi } @@ -288,7 +286,7 @@ jobs: } const parsedArtifacts = fs.readdirSync('./outputs').map(fileName => { - const [type, language] = fileName.split("-"); + const [type, language] = fileName.split("+"); const header = Object.entries(replaceTable).reduce((acc, [key, value]) => { return acc.replace(new RegExp(key, "g"), value); From 3a059b72469ee2d377a82d8bbcd2a3addddd11e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 14 Oct 2023 18:53:45 +0300 Subject: [PATCH 118/137] chore: test --- .github/workflows/comment-diffs.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 4d172831f..f207056a6 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -223,11 +223,11 @@ jobs: done done - if ls "$output_path/*.txt"; then - echo "DIFF_IS_NON_EMPTY=1" >> $GITHUB_OUTPUT - else - echo "DIFF_IS_NON_EMPTY=0" >> $GITHUB_OUTPUT - fi + # if ls "$output_path/*.txt"; then + # echo "DIFF_IS_NON_EMPTY=1" >> $GITHUB_OUTPUT + # else + # echo "DIFF_IS_NON_EMPTY=0" >> $GITHUB_OUTPUT + # fi # Remove outputs if it exists rm -rf ./outputs || true From 35dbfe99ecdbfb50c0f83fd9c054c16f7757fe15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 14 Oct 2023 18:57:59 +0300 Subject: [PATCH 119/137] chore: test --- .github/workflows/comment-diffs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index f207056a6..9746c80bb 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -224,7 +224,7 @@ jobs: done # if ls "$output_path/*.txt"; then - # echo "DIFF_IS_NON_EMPTY=1" >> $GITHUB_OUTPUT + echo "DIFF_IS_NON_EMPTY=1" >> $GITHUB_OUTPUT # else # echo "DIFF_IS_NON_EMPTY=0" >> $GITHUB_OUTPUT # fi From effaadaa6e9b48e80962ccb7bc2bc75f6698a056 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 14 Oct 2023 19:03:35 +0300 Subject: [PATCH 120/137] chore: join string --- .github/workflows/comment-diffs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 9746c80bb..796969444 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -299,7 +299,7 @@ jobs: const body = `🤓☝️ This PR changes the output of \`create-react-native-library\`. You can find the diffs of effected templates below: - ${parsedArtifacts} + ${parsedArtifacts.join("")} `; const comments = await github.issues.listComments({ From 1bb454737e539c11ed5083aef3c270d332099fd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 14 Oct 2023 19:09:03 +0300 Subject: [PATCH 121/137] chore: fix --- .github/workflows/comment-diffs.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 796969444..33ca72f23 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -223,11 +223,11 @@ jobs: done done - # if ls "$output_path/*.txt"; then - echo "DIFF_IS_NON_EMPTY=1" >> $GITHUB_OUTPUT - # else - # echo "DIFF_IS_NON_EMPTY=0" >> $GITHUB_OUTPUT - # fi + if ls $output_path/*.txt; then + echo "DIFF_IS_NON_EMPTY=1" >> $GITHUB_OUTPUT + else + echo "DIFF_IS_NON_EMPTY=0" >> $GITHUB_OUTPUT + fi # Remove outputs if it exists rm -rf ./outputs || true @@ -282,7 +282,8 @@ jobs: "java-objc": "Java and Objective C", "java-swift": "Java and Swift", "kotlin-objc": "Kotlin and Objective C", - "kotlin-swift": "Kotlin and Swift" + "kotlin-swift": "Kotlin and Swift", + ".txt": "" } const parsedArtifacts = fs.readdirSync('./outputs').map(fileName => { From 64fa7c292c0619d7792b6c65a1e5c374f22dae50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 14 Oct 2023 19:12:47 +0300 Subject: [PATCH 122/137] chore: change order --- .github/workflows/comment-diffs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 33ca72f23..38486e3bf 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -291,7 +291,7 @@ jobs: const header = Object.entries(replaceTable).reduce((acc, [key, value]) => { return acc.replace(new RegExp(key, "g"), value); - }, `${type} ${language}`); + }, `${language} ${type}`); const fileContents = fs.readFileSync(`./outputs/${fileName}`, 'utf8'); From de2b97b006e814e3d4b0f68fd138de6e61ed17aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 14 Oct 2023 19:20:25 +0300 Subject: [PATCH 123/137] chore: add condition to install again --- .github/workflows/comment-diffs.yml | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 38486e3bf..2ae88667f 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -8,7 +8,6 @@ on: - '.github/workflows/comment-diffs.yml' - 'packages/create-react-native-library/**' - '!**.md' -permissions: write-all jobs: generate-diffs-if-needed: @@ -31,9 +30,14 @@ jobs: - name: 📥 Monorepo install uses: ./.github/actions/setup with: - enable-corepack: false + cache-npm-cache: true cache-node-modules: true cache-install-state: true + + - name: Get hash of yarn lock + id: yarn-lock-hash + run: | + echo "YARN_LOCK_HASH=${{ hashFiles('./yarn.lock') }}" >> $GITHUB_OUTPUT - name: Build crnl run: | @@ -77,8 +81,13 @@ jobs: done done - # - name: Setup again # Add a check here to setup again if deps changed - # uses: ./.github/actions/setup + - name: Setup again # + if: ${{ steps.yarn-lock-hash.outputs.YARN_LOCK_HASH != hashFiles('./yarn.lock') }} + uses: ./.github/actions/setup + with: + cache-npm-cache: true + cache-node-modules: true + cache-install-state: true - name: Remove old build and build again run: | @@ -128,10 +137,7 @@ jobs: done - name: Remove everything - run: | - # Remove everything except the .git folder - for i in $(ls | grep -v ".git") ; do rm -rf "$i"; done; - rm -rf ./.git + run: for i in $(ls) ; do rm -rf "$i"; done; - name: Checkout # uses: checkout From f361d84035d76caeaa9ed5931990c0686bb8da8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 14 Oct 2023 19:24:58 +0300 Subject: [PATCH 124/137] chore: add leftpad to tset --- package.json | 3 +++ yarn.lock | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/package.json b/package.json index b015b0c30..2d2a2b1ad 100644 --- a/package.json +++ b/package.json @@ -55,5 +55,8 @@ "tabWidth": 2, "trailingComma": "es5", "useTabs": false + }, + "dependencies": { + "leftpad": "^0.0.1" } } diff --git a/yarn.lock b/yarn.lock index 685b43430..21da72dc8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8227,6 +8227,13 @@ __metadata: languageName: node linkType: hard +"leftpad@npm:^0.0.1": + version: 0.0.1 + resolution: "leftpad@npm:0.0.1" + checksum: ca725b724fe748086385d6bdea80a0b76519b8fddeec0d200e7eaa214a57ec5d8e2687561547478af57020418b1015be00c4ffb982b3100ca09b902ec87fb7ac + languageName: node + linkType: hard + "levn@npm:^0.4.1": version: 0.4.1 resolution: "levn@npm:0.4.1" @@ -11581,6 +11588,7 @@ __metadata: concurrently: ^7.2.2 eslint: ^8.18.0 eslint-config-satya164: ^3.1.11 + leftpad: ^0.0.1 prettier: ^2.7.1 typescript: ^5.0.2 languageName: unknown From c24360dd98da21645ca6c9ffbb8ab4a561ef158b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 14 Oct 2023 19:26:49 +0300 Subject: [PATCH 125/137] chore: disable some of the caching --- .github/workflows/comment-diffs.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 2ae88667f..92ff2d586 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -31,8 +31,8 @@ jobs: uses: ./.github/actions/setup with: cache-npm-cache: true - cache-node-modules: true - cache-install-state: true + cache-install-state: false + cache-node-modules: false - name: Get hash of yarn lock id: yarn-lock-hash @@ -86,8 +86,8 @@ jobs: uses: ./.github/actions/setup with: cache-npm-cache: true - cache-node-modules: true - cache-install-state: true + cache-install-state: false + cache-node-modules: false - name: Remove old build and build again run: | From e01ee62fab343f24db0830ae6e343b6575f0566e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 14 Oct 2023 19:29:25 +0300 Subject: [PATCH 126/137] chore: always install --- .github/workflows/comment-diffs.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 92ff2d586..0241e7a75 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -34,11 +34,6 @@ jobs: cache-install-state: false cache-node-modules: false - - name: Get hash of yarn lock - id: yarn-lock-hash - run: | - echo "YARN_LOCK_HASH=${{ hashFiles('./yarn.lock') }}" >> $GITHUB_OUTPUT - - name: Build crnl run: | yarn workspace create-react-native-library prepare @@ -81,8 +76,7 @@ jobs: done done - - name: Setup again # - if: ${{ steps.yarn-lock-hash.outputs.YARN_LOCK_HASH != hashFiles('./yarn.lock') }} + - name: Setup again uses: ./.github/actions/setup with: cache-npm-cache: true From a477ad41fd7bc25323924290f53ec2a8dfa83385 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 14 Oct 2023 19:32:35 +0300 Subject: [PATCH 127/137] chore: run yarn install at second time --- .github/workflows/comment-diffs.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 0241e7a75..ca17666c7 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -77,11 +77,7 @@ jobs: done - name: Setup again - uses: ./.github/actions/setup - with: - cache-npm-cache: true - cache-install-state: false - cache-node-modules: false + run: yarn install - name: Remove old build and build again run: | From 4e0628fafb01aff2d45b0814d1a96d1be1961253 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 14 Oct 2023 19:36:15 +0300 Subject: [PATCH 128/137] chore: cleanup --- .github/workflows/comment-diffs.yml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index ca17666c7..8cf5b2261 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -129,10 +129,8 @@ jobs: - name: Remove everything run: for i in $(ls) ; do rm -rf "$i"; done; - - name: Checkout - # uses: checkout - run: | - git init + - name: Create new empty repo + run: git init - name: Initiate diffs id: create-diffs @@ -141,9 +139,9 @@ jobs: source ../configMatrix/configMatrix.sh output_path="../outputs" - mkdir -p "$output_path" + # Set author git config --global user.email "text@test.com" git config --global user.name "Github actions test" @@ -225,7 +223,7 @@ jobs: echo "DIFF_IS_NON_EMPTY=0" >> $GITHUB_OUTPUT fi - # Remove outputs if it exists + # Remove outputs folder in cwd if it exists rm -rf ./outputs || true # Copy the outputs to cwd @@ -285,13 +283,13 @@ jobs: const parsedArtifacts = fs.readdirSync('./outputs').map(fileName => { const [type, language] = fileName.split("+"); - const header = Object.entries(replaceTable).reduce((acc, [key, value]) => { + const title = Object.entries(replaceTable).reduce((acc, [key, value]) => { return acc.replace(new RegExp(key, "g"), value); }, `${language} ${type}`); const fileContents = fs.readFileSync(`./outputs/${fileName}`, 'utf8'); - return `
${header}\n\n\`\`\`diff\n${fileContents}\n\`\`\`\n
\n\n`; + return `
${title}\n\n\`\`\`diff\n${fileContents}\n\`\`\`\n
\n\n`; }) const body = `🤓☝️ This PR changes the output of \`create-react-native-library\`. You can find the diffs of effected templates below: From 74b4abfb99b2f0f0cfdda0381b03bc1caca93f07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 14 Oct 2023 19:36:34 +0300 Subject: [PATCH 129/137] chore: remove some changes --- .../templates/common-example/example/metro.config.js | 1 - .../{%- project.package_dir %}/{%- project.name %}Module.java | 1 - 2 files changed, 2 deletions(-) diff --git a/packages/create-react-native-library/templates/common-example/example/metro.config.js b/packages/create-react-native-library/templates/common-example/example/metro.config.js index 7b623337c..b82321455 100644 --- a/packages/create-react-native-library/templates/common-example/example/metro.config.js +++ b/packages/create-react-native-library/templates/common-example/example/metro.config.js @@ -4,7 +4,6 @@ const escape = require('escape-string-regexp'); const exclusionList = require('metro-config/src/defaults/exclusionList'); const pak = require('../package.json'); -// Hi mom! const root = path.resolve(__dirname, '..'); const modules = Object.keys({ ...pak.peerDependencies }); diff --git a/packages/create-react-native-library/templates/java-library-legacy/android/src/main/java/com/{%- project.package_dir %}/{%- project.name %}Module.java b/packages/create-react-native-library/templates/java-library-legacy/android/src/main/java/com/{%- project.package_dir %}/{%- project.name %}Module.java index 6c8fd43cc..98948119c 100644 --- a/packages/create-react-native-library/templates/java-library-legacy/android/src/main/java/com/{%- project.package_dir %}/{%- project.name %}Module.java +++ b/packages/create-react-native-library/templates/java-library-legacy/android/src/main/java/com/{%- project.package_dir %}/{%- project.name %}Module.java @@ -8,7 +8,6 @@ import com.facebook.react.bridge.ReactMethod; import com.facebook.react.module.annotations.ReactModule; -// Hi mom! Is this thing on? @ReactModule(name = <%- project.name -%>Module.NAME) public class <%- project.name -%>Module extends ReactContextBaseJavaModule { public static final String NAME = "<%- project.name -%>"; From 0ac73374bad35f59f355b24eacff4cbaa798265a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 14 Oct 2023 19:36:55 +0300 Subject: [PATCH 130/137] Revert "chore: add leftpad to tset" This reverts commit 1366168533e769b6032e9f9790c1932ce0af736b. --- package.json | 3 --- yarn.lock | 8 -------- 2 files changed, 11 deletions(-) diff --git a/package.json b/package.json index 2d2a2b1ad..b015b0c30 100644 --- a/package.json +++ b/package.json @@ -55,8 +55,5 @@ "tabWidth": 2, "trailingComma": "es5", "useTabs": false - }, - "dependencies": { - "leftpad": "^0.0.1" } } diff --git a/yarn.lock b/yarn.lock index 21da72dc8..685b43430 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8227,13 +8227,6 @@ __metadata: languageName: node linkType: hard -"leftpad@npm:^0.0.1": - version: 0.0.1 - resolution: "leftpad@npm:0.0.1" - checksum: ca725b724fe748086385d6bdea80a0b76519b8fddeec0d200e7eaa214a57ec5d8e2687561547478af57020418b1015be00c4ffb982b3100ca09b902ec87fb7ac - languageName: node - linkType: hard - "levn@npm:^0.4.1": version: 0.4.1 resolution: "levn@npm:0.4.1" @@ -11588,7 +11581,6 @@ __metadata: concurrently: ^7.2.2 eslint: ^8.18.0 eslint-config-satya164: ^3.1.11 - leftpad: ^0.0.1 prettier: ^2.7.1 typescript: ^5.0.2 languageName: unknown From c7e923a8b7765daea1f753aa040368225c779885 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 14 Oct 2023 19:38:41 +0300 Subject: [PATCH 131/137] chore: improvements --- .github/workflows/comment-diffs.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 8cf5b2261..a78ab45cc 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -7,7 +7,6 @@ on: paths: - '.github/workflows/comment-diffs.yml' - 'packages/create-react-native-library/**' - - '!**.md' jobs: generate-diffs-if-needed: @@ -61,8 +60,7 @@ jobs: --type "$library_type" \ --languages "$language" \ --no-example \ - --no-local \ - --react-native-version 0.73.0-rc.2 + --no-local # Remove the .git folder of the created library rm -rf "$target_path/.git" @@ -111,8 +109,7 @@ jobs: --type "$library_type" \ --languages "$language" \ --no-example \ - --no-local \ - --react-native-version 0.73.0-rc.2 + --no-local # Remove the .git folder of the created library rm -rf "$target_path/.git" From 5b1e84e037251b1a09df65b3e7ccde68746178cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sat, 14 Oct 2023 19:41:33 +0300 Subject: [PATCH 132/137] chore: add temporarely --- .github/workflows/build-templates.yml | 261 ++++++++++++++++++++++++++ .github/workflows/check-project.yml | 27 +++ .github/workflows/deploy-docs.yml | 43 +++++ .github/workflows/rebase.yml | 28 +++ 4 files changed, 359 insertions(+) create mode 100644 .github/workflows/build-templates.yml create mode 100644 .github/workflows/check-project.yml create mode 100644 .github/workflows/deploy-docs.yml create mode 100644 .github/workflows/rebase.yml diff --git a/.github/workflows/build-templates.yml b/.github/workflows/build-templates.yml new file mode 100644 index 000000000..c5a1de290 --- /dev/null +++ b/.github/workflows/build-templates.yml @@ -0,0 +1,261 @@ +name: Build template +on: + workflow_dispatch: + push: + branches: + - main + paths: + - '.github/workflows/build-templates.yml' + - 'packages/create-react-native-library/**' + - '!**.md' + pull_request: + branches: + - main + +jobs: + build: + env: + TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} + TURBO_TEAM: ${{ secrets.TURBO_TEAM }} + + strategy: + fail-fast: false + matrix: + os: + - ubuntu + - macos + type: + - module-legacy + - module-mixed + - module-new + - view-legacy + - view-mixed + - view-new + language: + - java-objc + - java-swift + - kotlin-objc + - kotlin-swift + exclude: + - os: macos + language: kotlin-objc + - os: macos + language: kotlin-swift + - type: module-new + language: java-swift + - type: module-new + language: kotlin-swift + - type: module-mixed + language: java-swift + - type: module-mixed + language: kotlin-swift + - type: view-new + language: java-swift + - type: view-new + language: kotlin-swift + - type: view-mixed + language: java-swift + - type: view-mixed + language: kotlin-swift + include: + - os: ubuntu + type: library + language: js + - os: ubuntu + type: module-legacy + language: cpp + - os: ubuntu + type: module-mixed + language: cpp + - os: ubuntu + type: module-new + language: cpp + - os: macos + type: module-legacy + language: cpp + - os: macos + type: module-mixed + language: cpp + - os: macos + type: module-new + language: cpp + + concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.os }}-${{ matrix.type }}-${{ matrix.language }} + cancel-in-progress: true + + runs-on: ${{ matrix.os }}-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup + uses: ./.github/actions/setup + + - name: Build package + run: | + yarn workspace create-react-native-library prepare + + - name: Get working directory + run: | + echo "work_dir=${{ matrix.os }}-${{ matrix.type }}-${{ matrix.language }}" >> $GITHUB_ENV + + - name: Create library + run: | + rm -rf ${{ env.work_dir }} # Workaround for tests failing intermittently + ./packages/create-react-native-library/bin/create-react-native-library ${{ env.work_dir }} \ + --slug @bob/react-native-test \ + --description test \ + --author-name test \ + --author-email test@test \ + --author-url https://test.test \ + --repo-url https://test.test \ + --type ${{ matrix.type }} \ + --languages ${{ matrix.language }} \ + --no-local + + - name: Cache dependencies of library + id: library-yarn-cache + uses: actions/cache@v3 + with: + path: | + ${{ env.work_dir }}/**/node_modules + ${{ env.work_dir }}/**/yarn.lock + key: ${{ runner.os }}-library-yarn-${{ hashFiles(format('{0}/**/package.json', env.work_dir)) }} + restore-keys: | + ${{ runner.os }}-library-yarn- + + - name: Install dependencies of library + if: steps.library-yarn-cache.outputs.cache-hit != 'true' + working-directory: ${{ env.work_dir }} + run: | + touch yarn.lock # Without this Yarn will fail due to the parent directory being a Yarn workspace + rm -f example/yarn.lock # Workaround for cached yarn.lock from older version + yarn install --no-immutable + env: + POD_INSTALL: 0 + + - name: Get build target + working-directory: ${{ env.work_dir }} + run: | + # Build Android for only some matrices to skip redundant builds + if [[ ${{ matrix.os }} == ubuntu ]]; then + if [[ ${{ matrix.type }} == view-* && ${{ matrix.language }} == *-objc ]] || [[ ${{ matrix.type }} == module-* && ${{ matrix.language }} == *-objc ]] || [[ ${{ matrix.type }} == module-* && ${{ matrix.language }} == cpp ]]; then + echo "android_build=1" >> $GITHUB_ENV + fi + fi + + # Build iOS for only some matrices to skip redundant builds + if [[ ${{ matrix.os }} == macos ]]; then + if [[ ${{ matrix.type }} == view-* && ${{ matrix.language }} == java-* ]] || [[ ${{ matrix.type }} == module-* && ${{ matrix.language }} == java-* ]] || [[ ${{ matrix.type }} == module-* && ${{ matrix.language }} == cpp ]]; then + echo "ios_build=1" >> $GITHUB_ENV + fi + fi + + - name: Cache turborepo + if: env.android_build == 1 || env.ios_build == 1 + uses: actions/cache@v3 + with: + path: | + ${{ env.work_dir }}/.turbo + key: ${{ runner.os }}-library-turborepo-${{ matrix.type }}-${{ matrix.language }}-${{ hashFiles(format('{0}/**/yarn.lock', env.work_dir)) }} + restore-keys: | + ${{ runner.os }}-library-turborepo-${{ matrix.type }}-${{ matrix.language }}- + + - name: Check turborepo cache + if: env.android_build == 1 || env.ios_build == 1 + working-directory: ${{ env.work_dir }} + run: | + TURBO_CACHE_STATUS_ANDROID=$(node -p "($(yarn turbo run build:android --cache-dir=".turbo" --dry=json)).tasks.find(t => t.task === 'build:android').cache.status") + TURBO_CACHE_STATUS_IOS=$(node -p "($(yarn turbo run build:ios --cache-dir=".turbo" --dry=json)).tasks.find(t => t.task === 'build:ios').cache.status") + + if [[ $TURBO_CACHE_STATUS_ANDROID == "HIT" ]]; then + echo "turbo_cache_hit_android=1" >> $GITHUB_ENV + fi + + if [[ $TURBO_CACHE_STATUS_IOS == "HIT" ]]; then + echo "turbo_cache_hit_ios=1" >> $GITHUB_ENV + fi + + - name: Lint library + working-directory: ${{ env.work_dir }} + run: | + yarn lint + + - name: Typecheck library + working-directory: ${{ env.work_dir }} + run: | + yarn typecheck + + - name: Test library + working-directory: ${{ env.work_dir }} + run: | + yarn test + + - name: Build library + working-directory: ${{ env.work_dir }} + run: | + yarn prepare + + - name: Build example (Web) + working-directory: ${{ env.work_dir }} + if: matrix.language == 'js' + run: | + yarn example expo export:web + + - name: Install JDK + if: env.android_build == 1 && env.turbo_cache_hit_android != 1 + uses: actions/setup-java@v3 + with: + distribution: 'zulu' + java-version: '11' + + - name: Finalize Android SDK + if: env.android_build == 1 && env.turbo_cache_hit_android != 1 + run: | + /bin/bash -c "yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses > /dev/null" + + - name: Cache Gradle + if: env.android_build == 1 && env.turbo_cache_hit_android != 1 + uses: actions/cache@v3 + with: + path: | + ~/.gradle/wrapper + ~/.gradle/caches + key: ${{ runner.os }}-gradle-${{ hashFiles(format('{0}/example/android/gradle/wrapper/gradle-wrapper.properties', env.work_dir)) }} + restore-keys: | + ${{ runner.os }}-gradle- + + - name: Build example (Android) + if: env.android_build == 1 + working-directory: ${{ env.work_dir }} + run: | + yarn turbo run build:android --cache-dir=".turbo" + + - name: Cache cocoapods + if: env.ios_build == 1 && env.turbo_cache_hit_ios != 1 + id: library-cocoapods-cache + uses: actions/cache@v3 + with: + path: | + ${{ env.work_dir }}/**/ios/Pods + ${{ env.work_dir }}/**/ios/Podfile.lock + key: ${{ runner.os }}-library-cocoapods-${{ hashFiles(format('{0}/example/ios/Podfile', env.work_dir)) }}-${{ hashFiles(format('{0}/**/yarn.lock', env.work_dir)) }} + restore-keys: | + ${{ runner.os }}-library-cocoapods-${{ hashFiles(format('{0}/example/ios/Podfile', env.work_dir)) }}- + ${{ runner.os }}-library-cocoapods- + + - name: Install cocoapods + if: env.ios_build == 1 && env.turbo_cache_hit_ios != 1 && steps.library-cocoapods-cache.outputs.cache-hit != 'true' + working-directory: ${{ env.work_dir }} + run: | + yarn pod-install example/ios + env: + NO_FLIPPER: 1 + + - name: Build example (iOS) + if: env.ios_build == 1 + working-directory: ${{ env.work_dir }} + run: | + yarn turbo run build:ios --cache-dir=".turbo" diff --git a/.github/workflows/check-project.yml b/.github/workflows/check-project.yml new file mode 100644 index 000000000..af539d7c6 --- /dev/null +++ b/.github/workflows/check-project.yml @@ -0,0 +1,27 @@ +name: Check project +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + check-project: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup + uses: ./.github/actions/setup + + - name: Lint + run: yarn lint + + - name: Typecheck + run: yarn typecheck + + - name: Build packages + run: yarn lerna run prepare diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml new file mode 100644 index 000000000..69e82b69b --- /dev/null +++ b/.github/workflows/deploy-docs.yml @@ -0,0 +1,43 @@ +name: Deploy docs +on: + workflow_dispatch: + push: + branches: + - main + paths: + - '.github/workflows/deploy-docs.yml' + - 'docs/**' + +jobs: + deploy-docs: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup + uses: ./.github/actions/setup + + - name: Cache build + uses: actions/cache@v3 + with: + path: | + docs/.next/cache + key: ${{ runner.os }}-nextjs-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('**/package.json') }} + restore-keys: | + ${{ runner.os }}-nextjs-${{ hashFiles('**/yarn.lock') }} + ${{ runner.os }}-nextjs- + + - name: Build docs + run: | + yarn docs build + touch docs/out/.nojekyll + + - name: Deploy to GitHub Pages + uses: JamesIves/github-pages-deploy-action@v4 + with: + branch: gh-pages + folder: docs/out + +permissions: + contents: write diff --git a/.github/workflows/rebase.yml b/.github/workflows/rebase.yml new file mode 100644 index 000000000..af3db7e59 --- /dev/null +++ b/.github/workflows/rebase.yml @@ -0,0 +1,28 @@ +name: Automatic Rebase +on: + issue_comment: + types: [created] + +jobs: + rebase: + name: Rebase + if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '/rebase') + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Automatic Rebase + uses: cirrus-actions/rebase@1.2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + # https://github.community/t5/GitHub-Actions/Workflow-is-failing-if-no-job-can-be-ran-due-to-condition/m-p/38186#M3250 + always_job: + name: Always run job + runs-on: ubuntu-latest + steps: + - name: Always run + run: echo "This job is used to prevent the workflow to fail when all other jobs are skipped." From d3d14c716004f6729ba9bc92ec58139aff1c26eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sun, 15 Oct 2023 16:57:29 +0300 Subject: [PATCH 133/137] chore: use rn 0.73.0 rc on build templates workflow --- .github/workflows/build-templates.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-templates.yml b/.github/workflows/build-templates.yml index c5a1de290..f6dec81e0 100644 --- a/.github/workflows/build-templates.yml +++ b/.github/workflows/build-templates.yml @@ -113,7 +113,8 @@ jobs: --repo-url https://test.test \ --type ${{ matrix.type }} \ --languages ${{ matrix.language }} \ - --no-local + --no-local \ + --react-native-version 0.73.0-rc.2 - name: Cache dependencies of library id: library-yarn-cache From 8016ada4f05956e9235f4c57b04146106ed0ab29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sun, 15 Oct 2023 17:08:07 +0300 Subject: [PATCH 134/137] Revert "chore: use rn 0.73.0 rc on build templates workflow" This reverts commit d3d14c716004f6729ba9bc92ec58139aff1c26eb. --- .github/workflows/build-templates.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build-templates.yml b/.github/workflows/build-templates.yml index f6dec81e0..c5a1de290 100644 --- a/.github/workflows/build-templates.yml +++ b/.github/workflows/build-templates.yml @@ -113,8 +113,7 @@ jobs: --repo-url https://test.test \ --type ${{ matrix.type }} \ --languages ${{ matrix.language }} \ - --no-local \ - --react-native-version 0.73.0-rc.2 + --no-local - name: Cache dependencies of library id: library-yarn-cache From 3d58cf5625c3e827c22fdc15980f264d637d4e84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Sun, 15 Oct 2023 17:14:25 +0300 Subject: [PATCH 135/137] chore: fix typo --- .github/workflows/comment-diffs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index a78ab45cc..4f47e24a4 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -289,7 +289,7 @@ jobs: return `
${title}\n\n\`\`\`diff\n${fileContents}\n\`\`\`\n
\n\n`; }) - const body = `🤓☝️ This PR changes the output of \`create-react-native-library\`. You can find the diffs of effected templates below: + const body = `🤓☝️ This PR changes the output of \`create-react-native-library\`. You can find the diffs of affected templates below: ${parsedArtifacts.join("")} `; From 0038348d31f1f65f239f827857e820c3adcfb4c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Fri, 27 Oct 2023 14:46:35 +0300 Subject: [PATCH 136/137] chore: use the old install action --- .github/actions/setup/action.yml | 134 ++++------------------------ .github/workflows/comment-diffs.yml | 12 +-- 2 files changed, 22 insertions(+), 124 deletions(-) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 2b00b529e..e26611925 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -1,125 +1,27 @@ -# https://gist.github.com/belgattitude/042f9caf10d029badbde6cf9d43e400a - -######################################################################################## -# "yarn install" composite action for yarn 3/4+ and "nodeLinker: node-modules" # -#--------------------------------------------------------------------------------------# -# Requirement: @setup/node should be run before # -# # -# Usage in workflows steps: # -# # -# - name: 📥 Monorepo install # -# uses: ./.github/actions/yarn-nm-install # -# with: # -# enable-corepack: false # (default = 'false') # -# cwd: ${{ github.workspace }}/apps/my-app # (default = '.') # -# cache-prefix: add cache key prefix # (default = 'default') # -# cache-node-modules: false # (default = 'false') # -# cache-install-state: false # (default = 'false') # -# # -# Reference: # -# - latest: https://gist.github.com/belgattitude/042f9caf10d029badbde6cf9d43e400a # -# # -# Versions: # -# - 1.1.0 - 22-07-2023 - Option to enable npm global cache folder. # -# - 1.0.4 - 15-07-2023 - Fix corepack was always enabled. # -# - 1.0.3 - 05-07-2023 - YARN_ENABLE_MIRROR to false (speed up cold start) # -# - 1.0.2 - 02-06-2023 - install-state default to false # -# - 1.0.1 - 29-05-2023 - cache-prefix doc # -# - 1.0.0 - 27-05-2023 - new input: cache-prefix # -######################################################################################## - -name: 'Monorepo install (yarn)' -description: 'Run yarn install with node_modules linker and cache enabled' -inputs: - cwd: - description: "Changes node's process.cwd() if the project is not located on the root. Default to process.cwd()" - required: false - default: '.' - cache-prefix: - description: 'Add a specific cache-prefix' - required: false - default: 'default' - cache-npm-cache: - description: 'Cache npm global cache folder often used by node-gyp, prebuild binaries (invalidated on lock/os/node-version)' - required: false - default: 'true' - cache-node-modules: - description: 'Cache node_modules, might speed up link step (invalidated lock/os/node-version/branch)' - required: false - default: 'false' - cache-install-state: - description: 'Cache yarn install state, might speed up resolution step when node-modules cache is activated (invalidated lock/os/node-version/branch)' - required: false - default: 'false' - enable-corepack: - description: 'Enable corepack' - required: false - default: 'true' +name: Setup +description: Setup Node.js and install dependencies runs: - using: 'composite' - + using: composite steps: - - name: ⚙️ Enable Corepack - if: inputs.enable-corepack == 'true' - shell: bash - working-directory: ${{ inputs.cwd }} - run: corepack enable - - - name: ⚙️ Expose yarn config as "$GITHUB_OUTPUT" - id: yarn-config - shell: bash - working-directory: ${{ inputs.cwd }} - env: - YARN_ENABLE_GLOBAL_CACHE: 'false' - run: | - echo "CACHE_FOLDER=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT - echo "CURRENT_NODE_VERSION="node-$(node --version)"" >> $GITHUB_OUTPUT - echo "CURRENT_BRANCH=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's,/,-,g')" >> $GITHUB_OUTPUT - echo "NPM_GLOBAL_CACHE_FOLDER=$(npm config get cache)" >> $GITHUB_OUTPUT - - - name: ♻️ Restore yarn cache - uses: actions/cache@v3 - id: yarn-download-cache + - name: Setup Node.js + uses: actions/setup-node@v3 with: - path: ${{ steps.yarn-config.outputs.CACHE_FOLDER }} - key: yarn-download-cache-${{ inputs.cache-prefix }}-${{ hashFiles(format('{0}/yarn.lock', inputs.cwd), format('{0}/.yarnrc.yml', inputs.cwd)) }} - restore-keys: | - yarn-download-cache-${{ inputs.cache-prefix }}- - - - name: ♻️ Restore node_modules - if: inputs.cache-node-modules == 'true' - id: yarn-nm-cache - uses: actions/cache@v3 - with: - path: ${{ inputs.cwd }}/**/node_modules - key: yarn-nm-cache-${{ inputs.cache-prefix }}-${{ runner.os }}-${{ steps.yarn-config.outputs.CURRENT_NODE_VERSION }}-${{ steps.yarn-config.outputs.CURRENT_BRANCH }}-${{ hashFiles(format('{0}/yarn.lock', inputs.cwd), format('{0}/.yarnrc.yml', inputs.cwd)) }} + node-version-file: .nvmrc - - name: ♻️ Restore global npm cache folder - if: inputs.cache-npm-cache == 'true' - id: npm-global-cache + - name: Cache dependencies + id: yarn-cache uses: actions/cache@v3 with: - path: ${{ steps.yarn-config.outputs.NPM_GLOBAL_CACHE_FOLDER }} - key: npm-global-cache-${{ inputs.cache-prefix }}-${{ runner.os }}-${{ steps.yarn-config.outputs.CURRENT_NODE_VERSION }}-${{ hashFiles(format('{0}/yarn.lock', inputs.cwd), format('{0}/.yarnrc.yml', inputs.cwd)) }} - - - name: ♻️ Restore yarn install state - if: inputs.cache-install-state == 'true' && inputs.cache-node-modules == 'true' - id: yarn-install-state-cache - uses: actions/cache@v3 - with: - path: ${{ inputs.cwd }}/.yarn/ci-cache - key: yarn-install-state-cache-${{ inputs.cache-prefix }}-${{ runner.os }}-${{ steps.yarn-config.outputs.CURRENT_NODE_VERSION }}-${{ steps.yarn-config.outputs.CURRENT_BRANCH }}-${{ hashFiles(format('{0}/yarn.lock', inputs.cwd), format('{0}/.yarnrc.yml', inputs.cwd)) }} + path: | + **/node_modules + .yarn/install-state.gz + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('**/package.json') }} + restore-keys: | + ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + ${{ runner.os }}-yarn- - - name: 📥 Install dependencies + - name: Install dependencies + if: steps.yarn-cache.outputs.cache-hit != 'true' + run: yarn install --immutable shell: bash - working-directory: ${{ inputs.cwd }} - run: yarn install --immutable --inline-builds - env: - # Overrides/align yarnrc.yml options (v3, v4) for a CI context - YARN_ENABLE_GLOBAL_CACHE: 'false' # Use local cache folder to keep downloaded archives - YARN_ENABLE_MIRROR: 'false' # Prevent populating global cache for caches misses (local cache only) - YARN_NM_MODE: 'hardlinks-local' # Reduce node_modules size - YARN_INSTALL_STATE_PATH: '.yarn/ci-cache/install-state.gz' # Might speed up resolution step when node_modules present - # Other environment variables - HUSKY: '0' # By default do not run HUSKY install diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 4f47e24a4..88902c297 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -26,13 +26,9 @@ jobs: with: node-version-file: .nvmrc - - name: 📥 Monorepo install + - name: Setup uses: ./.github/actions/setup - with: - cache-npm-cache: true - cache-install-state: false - cache-node-modules: false - + - name: Build crnl run: | yarn workspace create-react-native-library prepare @@ -74,8 +70,8 @@ jobs: done done - - name: Setup again - run: yarn install + - name: Setup + uses: ./.github/actions/setup - name: Remove old build and build again run: | From 73a3a3571a013b5e63cb99c48a844323dc1a5864 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Gu=CC=88ner?= Date: Fri, 27 Oct 2023 17:35:42 +0300 Subject: [PATCH 137/137] chore: improve readability --- .github/workflows/comment-diffs.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/comment-diffs.yml b/.github/workflows/comment-diffs.yml index 88902c297..bb171ec68 100644 --- a/.github/workflows/comment-diffs.yml +++ b/.github/workflows/comment-diffs.yml @@ -119,13 +119,13 @@ jobs: done done - - name: Remove everything + - name: Remove everything in the working directory run: for i in $(ls) ; do rm -rf "$i"; done; - name: Create new empty repo run: git init - - name: Initiate diffs + - name: Create diffs id: create-diffs run: | # Source all the configuration values to load $languages, $types, and $exclude @@ -136,7 +136,7 @@ jobs: # Set author git config --global user.email "text@test.com" - git config --global user.name "Github actions test" + git config --global user.name "create-react-native-library diff generator action" function copy_commit_diff(){ library_type=$1 @@ -195,10 +195,9 @@ jobs: # Add output to file # echo "[$library_type/$language](https://github.com/${{github.repository}}/compare/$old_version_commit_hash..$new_version_commit_hash)" >> "$output_file" + + # Write the diff to the output file git diff HEAD~ >> $output_file - echo "$output_file" - - cat "$output_file" fi }