Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: enhance CI tests #3344

Merged
merged 5 commits into from
Dec 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/setup-node/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ runs:
if: steps.yarn-cache.outputs.cache-hit != 'true'
run: yarn install --immutable --ignore-scripts
shell: bash

34 changes: 34 additions & 0 deletions .github/workflows/check-android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Check Android

on:
push:
branches:
- master
paths:
- '.github/workflows/check-android.yml'
- 'android/**'
pull_request:
paths:
- '.github/workflows/check-android.yml'
- 'android/**'

jobs:
Kotlin-Lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: |
curl -sSLO https://github.com/pinterest/ktlint/releases/download/1.0.0/ktlint && chmod a+x ktlint && sudo mv ktlint /usr/local/bin/
- name: run ktlint
working-directory: ./android/
run: |
ktlint --reporter=checkstyle,output=build/ktlint-report.xml --relative --editorconfig=./.editorconfig
continue-on-error: true
- uses: yutailang0119/action-ktlint@v3
with:
report-path: ./android/build/*.xml
continue-on-error: false
- uses: actions/upload-artifact@v3
with:
name: ktlint-report
path: ./android/build/*.xml
31 changes: 31 additions & 0 deletions .github/workflows/check-clang.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Check CLang

on:
push:
branches:
- master
paths:
- '.github/workflows/check-clang.yml'
- 'ios/**'
pull_request:
branches:
- master
paths:
- '.github/workflows/check-clang.yml'
- 'ios/**'

jobs:
CLang-Format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install clang-format
run: sudo apt-get install clang-format
- name: Check ios clang formatting
run: |
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
41 changes: 41 additions & 0 deletions .github/workflows/check-ios.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Check iOS

on:
push:
branches:
- master
paths:
- '.github/workflows/check-ios.yml'
- 'ios/**'
pull_request:
paths:
- '.github/workflows/check-ios.yml'
- 'ios/**'

jobs:
Swift-Lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Lint with SwiftLint
uses: norio-nomura/action-swiftlint@master
with:
args: --strict
env:
WORKING_DIRECTORY: ios
Swift-Format:
runs-on: macOS-latest
defaults:
run:
working-directory: ./ios
steps:
- uses: actions/checkout@v4

- name: Install SwiftFormat
run: brew install swiftformat

- name: Format Swift code
run: swiftformat --verbose .

- name: Verify formatted code is unchanged
run: git diff --exit-code HEAD
2 changes: 1 addition & 1 deletion .github/workflows/check-js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ jobs:
run: yarn lint --fix

- name: Verify no files have changed after auto-fix
run: git diff --exit-code HEAD
run: git diff --exit-code HEAD
14 changes: 14 additions & 0 deletions android/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[*.{kt,kts}]
indent_style=space
indent_size=2
continuation_indent_size=4
insert_final_newline=true
max_line_length=160
ktlint_code_style=android_studio
ktlint_standard=enabled
ktlint_experimental=enabled
ktlint_standard_filename=disabled # dont require PascalCase filenames
ktlint_standard_no-wildcard-imports=disabled # allow .* imports
ktlint_function_signature_body_expression_wrapping=multiline
ij_kotlin_allow_trailing_comma_on_call_site=false
ij_kotlin_allow_trailing_comma=false
25 changes: 25 additions & 0 deletions ios/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Config for clang-format version 16

# standard
BasedOnStyle: llvm
Standard: c++14

# Indentation
IndentWidth: 2
ColumnLimit: 140

# Includes
SortIncludes: true
SortUsingDeclarations: true

# Pointer and reference alignment
PointerAlignment: Left
ReferenceAlignment: Left
ReflowComments: true

# Line breaking options
BreakBeforeBraces: Attach
BreakConstructorInitializers: BeforeColon
AllowShortFunctionsOnASingleLine: Empty
IndentCaseLabels: true
NamespaceIndentation: Inner
13 changes: 13 additions & 0 deletions ios/.swiftformat
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--allman false
--indent 2
--exclude Pods,Generated

--disable andOperator
--disable redundantReturn
--disable wrapMultilineStatementBraces
--disable organizeDeclarations
--disable redundantSelf

--enable markTypes

--enable isEmpty
51 changes: 51 additions & 0 deletions ios/.swiftlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
disabled_rules:
- identifier_name
- trailing_comma
- todo
- type_body_length
- file_length
- cyclomatic_complexity
- function_body_length
opt_in_rules:
- contains_over_filter_count
- contains_over_filter_is_empty
- contains_over_first_not_nil
- contains_over_range_nil_comparison
- empty_collection_literal
- empty_count
- empty_string
- first_where
- flatmap_over_map_reduce
- last_where
- reduce_boolean
- reduce_into
- yoda_condition
- vertical_whitespace_opening_braces
- vertical_whitespace_closing_braces
- vertical_parameter_alignment_on_call
- untyped_error_in_catch
- unowned_variable_capture
- unavailable_function
- switch_case_on_newline
- static_operator
- strict_fileprivate
- sorted_imports
- sorted_first_last
- required_enum_case
- redundant_type_annotation
- redundant_nil_coalescing
- attributes
- convenience_type
analyzer_rules:
- explicit_self
- unused_declaration
- unused_import

excluded: # paths to ignore during linting. Takes precedence over `included`.
- Pods

# Adjust rule numbers
line_length: 160

# reporter type (xcode, json, csv, checkstyle, codeclimate, junit, html, emoji, sonarqube, markdown, github-actions-logging)
reporter: "xcode"
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,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",
Expand All @@ -45,7 +46,9 @@
"xbasic": "yarn --cwd examples/basic",
"docs": "yarn --cwd docs build",
"release": "release-it",
"test": "echo no test available"
"test": "echo no test available",
"check-ios": "scripts/swift-format.sh && scripts/swift-lint.sh && scripts/clang-format.sh",
"check-android": "scripts/kotlin-lint.sh"
},
"files": [
"android",
Expand Down
26 changes: 26 additions & 0 deletions scripts/bootstrap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/* eslint-disable @typescript-eslint/no-var-requires */

const path = require('path');
const child_process = require('child_process');

const root = path.resolve(__dirname, '..');
const args = process.argv.slice(2);
const options = {
cwd: process.cwd(),
env: process.env,
stdio: 'inherit',
encoding: 'utf-8',
};

let result;

if (process.cwd() !== root || args.length) {
// We're not in the root of the project, or additional arguments were passed
// In this case, forward the command to `yarn`
result = child_process.spawnSync('yarn', args, options);
} else {
// If `yarn` is run without arguments, perform bootstrap
result = child_process.spawnSync('yarn', ['bootstrap'], options);
}

process.exitCode = result.status;
9 changes: 9 additions & 0 deletions scripts/clang-format.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

if which clang-format >/dev/null; then
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
else
echo "[ERROR]: clang-format is not installed - Install with 'brew install clang-format' (or manually from https://clang.llvm.org/docs/ClangFormat.html)"
fi
7 changes: 7 additions & 0 deletions scripts/kotlin-lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

if which ktlint >/dev/null; then
cd android && ktlint --color --relative --editorconfig=./.editorconfig -F ./**/*.kt*
else
echo "[ERROR]: KTLint is not installed - Install with 'brew install ktlint' (or manually from https://github.com/pinterest/ktlint)"
fi
7 changes: 7 additions & 0 deletions scripts/swift-format.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

if which swiftformat >/dev/null; then
cd ios && swiftformat --quiet .
else
echo "[ERROR]: SwiftFormat is not installed -Install with 'brew install swiftformat' (or manually from https://github.com/nicklockwood/SwiftFormat)"
fi
7 changes: 7 additions & 0 deletions scripts/swift-lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

if which swiftlint >/dev/null; then
cd ios && swiftlint --quiet --fix && swiftlint --quiet
else
echo "[ERROR]: SwiftLint is not installed - Install with 'brew install swiftlint' (or manually from https://github.com/realm/SwiftLint)"
fi
Loading