diff --git a/.github/actions/setup-node/action.yml b/.github/actions/setup-node/action.yml new file mode 100644 index 0000000000..e131e408eb --- /dev/null +++ b/.github/actions/setup-node/action.yml @@ -0,0 +1,34 @@ +name: Setup node_modules +description: Setup Node.js and install dependencies + +inputs: + working-directory: + description: 'working directory for yarn install' + default: ./ + required: false + +runs: + using: composite + steps: + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: 18.x + + - name: Cache dependencies + id: yarn-cache + uses: actions/cache@v3 + with: + path: | + **/node_modules + .yarn/install-state.gz + key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}-${{ hashFiles('**/package.json', '!node_modules/**') }} + restore-keys: | + ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }} + ${{ runner.os }}-yarn- + - name: Install dependencies + working-directory: ${{ inputs.working-directory }} + if: steps.yarn-cache.outputs.cache-hit != 'true' + run: yarn install --immutable --ignore-scripts + shell: bash + \ No newline at end of file diff --git a/.github/workflows/check-android.yml b/.github/workflows/check-android.yml index 59fe1dfab2..b5e4e16568 100644 --- a/.github/workflows/check-android.yml +++ b/.github/workflows/check-android.yml @@ -31,4 +31,4 @@ jobs: - uses: actions/upload-artifact@v3 with: name: ktlint-report - path: ./android/build/*.xml \ No newline at end of file + path: ./android/build/*.xml diff --git a/.github/workflows/check-clang.yml b/.github/workflows/check-clang.yml index 25d7642581..86433c94f5 100644 --- a/.github/workflows/check-clang.yml +++ b/.github/workflows/check-clang.yml @@ -21,7 +21,11 @@ jobs: - uses: actions/checkout@v4 - name: Install clang-format run: sudo apt-get install clang-format - - name: Check formatting + - name: Check ios clang formatting run: | - git diff --name-only --diff-filter=d origin/main...HEAD | grep -E '\.(h|m|mm)$' | xargs clang-format -i -style=file:./ios/.clang-format - git diff --exit-code HEAD \ No newline at end of file + find ios -type f \( -name "*.h" -o -name "*.cpp" -o -name "*.m" -o -name "*.mm" \) -print0 | while read -d $'\0' file; do + clang-format -style=file:./ios/.clang-format -i "$file" + done + shell: bash + - name: Check for changes + run: git diff --exit-code HEAD diff --git a/.github/workflows/check-ios.yml b/.github/workflows/check-ios.yml index 9ce35e0f04..621522de7b 100644 --- a/.github/workflows/check-ios.yml +++ b/.github/workflows/check-ios.yml @@ -38,4 +38,4 @@ jobs: run: swiftformat --verbose . - name: Verify formatted code is unchanged - run: git diff --exit-code HEAD \ No newline at end of file + run: git diff --exit-code HEAD diff --git a/.github/workflows/check-js.yml b/.github/workflows/check-js.yml index 2ccc1b43af..c9f7bd3df8 100644 --- a/.github/workflows/check-js.yml +++ b/.github/workflows/check-js.yml @@ -30,28 +30,18 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Get yarn cache directory path - id: yarn-cache-dir-path - run: echo "::set-output name=dir::$(yarn cache dir)" - - name: Restore node_modules from cache - uses: actions/cache@v3 - id: yarn-cache - with: - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} - key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} - restore-keys: | - ${{ runner.os }}-yarn- - name: Install node_modules - run: yarn install --frozen-lockfile + uses: ./.github/actions/setup-node - - uses: EPMatt/reviewdog-action-tsc@v1 - with: - github_token: ${{ secrets.github_token }} - reporter: github-pr-review - level: warning - fail_on_error: true - + - name: Install reviewdog + uses: reviewdog/action-setup@v1 + + - name: Check TypeScript + run: | + yarn tsc | reviewdog -name="tsc" -efm="%f(%l,%c): error TS%n: %m" -reporter="github-pr-review" -filter-mode="nofilter" -fail-on-error -tee + env: + REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} JS-Lint: name: Lint JS (eslint, prettier) @@ -59,20 +49,8 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Get yarn cache directory path - id: yarn-cache-dir-path - run: echo "::set-output name=dir::$(yarn cache dir)" - - name: Restore node_modules from cache - uses: actions/cache@v3 - id: yarn-cache - with: - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} - key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} - restore-keys: | - ${{ runner.os }}-yarn- - - name: Install node_modules - run: yarn install --frozen-lockfile + uses: ./.github/actions/setup-node - name: Run ESLint run: yarn lint -f @jamesacarr/github-actions @@ -81,4 +59,4 @@ jobs: run: yarn lint --fix - name: Verify no files have changed after auto-fix - run: git diff --exit-code HEAD \ No newline at end of file + run: git diff --exit-code HEAD diff --git a/package.json b/package.json index b01d720820..d08ec04911 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "@types/react": "~18.0.0", "@types/react-native": "0.72.3", "@typescript-eslint/eslint-plugin": "^6.7.4", + "@jamesacarr/eslint-formatter-github-actions": "^0.2.0", "eslint": "^8.19.0", "eslint-plugin-jest": "^27.4.2", "jest": "^29.7.0",