diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 000000000..12682e978 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @raccoongang/educationx-app-ios-reviewers diff --git a/.github/ISSUE_TEMPLATE/bug.yml b/.github/ISSUE_TEMPLATE/bug.yml new file mode 100644 index 000000000..3629bf272 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug.yml @@ -0,0 +1,56 @@ +name: Bug report for the EducationX IOS app +description: Report any issues that you have found with the EducationX IOS app. Please [check open issues](https://github.com/raccoongang/educationx-app-ios/issues) first, in case it has already been reported. +labels: [Bug] +body: + - type: markdown + attributes: + value: | + Thanks for taking the time to fill out this bug report! + + Please report security issues by email to security@raccoongang.com + - type: textarea + id: reproduction-steps + attributes: + label: Steps to reproduce + description: Please attach screenshots, videos or logs if you can. + placeholder: Tell us what you see! + value: | + 1. Where are you starting? What can you see? + 2. What do you click? + 3. More steps… + validations: + required: true + - type: textarea + id: result + attributes: + label: Outcome + placeholder: Tell us what went wrong + value: | + #### What did you expect? + + #### What happened instead? + validations: + required: true + - type: input + id: device + attributes: + label: Your phone model + placeholder: e.g. iPhoneX + validations: + required: false + - type: input + id: os + attributes: + label: Operating system version + placeholder: e.g. iOS14.7.1, under "software version" + validations: + required: false + - type: input + id: version + attributes: + label: Application version + description: You can find the version information in the Settings of EducationX IOS. + placeholder: | + e.g. Version: v1.2.2 + validations: + required: false diff --git a/.github/ISSUE_TEMPLATE/config.yaml b/.github/ISSUE_TEMPLATE/config.yaml new file mode 100644 index 000000000..3ba13e0ce --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yaml @@ -0,0 +1 @@ +blank_issues_enabled: false diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 000000000..bbcbbe7d6 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: '' +assignees: '' + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml new file mode 100644 index 000000000..e9d655c49 --- /dev/null +++ b/.github/workflows/unit_tests.yml @@ -0,0 +1,60 @@ +name: Unit Tests + +on: + workflow_dispatch: + + push: + branches: [ develop ] + + pull_request: + +jobs: + tests: + name: Tests + runs-on: macos-13 + + concurrency: + # When running on develop, use the sha to allow all runs of this workflow to run concurrently. + # Otherwise only allow a single run of this workflow on each branch, automatically cancelling older runs. + group: ${{ github.ref == 'refs/heads/develop' && format('unit-tests-develop-{0}', github.sha) || format('unit-tests-{0}', github.ref) }} + cancel-in-progress: true + + steps: + - uses: nschloe/action-cached-lfs-checkout@v1.2.1 + with: + ref: ${{ github.event.pull_request.head.sha }} + + - uses: actions/cache@v3 + with: + path: vendor/bundle + key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }} + restore-keys: | + ${{ runner.os }}-gems- + + - name: Setup environment + run: + source ci_scripts/ci_prepare_env.sh && setup_github_actions_environment + + - run: | + xcversion installed + + - name: SwiftLint + run: + bundle exec fastlane linting + + - name: Run tests + run: bundle exec fastlane unit_tests + + - name: Archive artifacts + uses: actions/upload-artifact@v3 + if: always() + with: + name: test-output + path: fastlane/test_output + retention-days: 7 + if-no-files-found: ignore + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v3 + with: + flags: unittests diff --git a/.gitignore b/.gitignore index 998e24696..36e2b2501 100644 --- a/.gitignore +++ b/.gitignore @@ -98,3 +98,6 @@ iOSInjectionProject/ .DS_Store .idea xcode-frameworks + +vendor/ +.bundle/ \ No newline at end of file diff --git a/.swiftlint.yml b/.swiftlint.yml index 5cf8633aa..f6b96b50b 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -24,6 +24,7 @@ excluded: # paths to ignore during linting. Takes precedence over `included`. - Discovery/DiscoveryTests - Discussion/DiscussionTests - Profile/ProfileTests + - vendor # - Source/ExcludedFolder # - Source/ExcludedFile.swift # - Source/*/ExcludedFile.swift # Exclude files with a wildcard diff --git a/Gemfile b/Gemfile index 7a118b49b..42dff7037 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,4 @@ source "https://rubygems.org" gem "fastlane" +gem "xcode-install" diff --git a/Gemfile.lock b/Gemfile.lock index 0ee64adc5..8d7c4d571 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -66,7 +66,7 @@ GEM faraday_middleware (1.2.0) faraday (~> 1.0) fastimage (2.2.7) - fastlane (2.213.0) + fastlane (2.214.0) CFPropertyList (>= 2.3, < 4.0.0) addressable (>= 2.8, < 3.0.0) artifactory (~> 3.0) @@ -196,6 +196,9 @@ GEM unicode-display_width (1.8.0) webrick (1.8.1) word_wrap (1.0.0) + xcode-install (2.8.1) + claide (>= 0.9.1) + fastlane (>= 2.1.0, < 3.0.0) xcodeproj (1.22.0) CFPropertyList (>= 2.3.3, < 4.0) atomos (~> 0.1.3) @@ -213,6 +216,7 @@ PLATFORMS DEPENDENCIES fastlane + xcode-install BUNDLED WITH 2.4.10 diff --git a/ci_scripts/ci_prepare_env.sh b/ci_scripts/ci_prepare_env.sh new file mode 100644 index 000000000..206dcde33 --- /dev/null +++ b/ci_scripts/ci_prepare_env.sh @@ -0,0 +1,43 @@ +#!/bin/sh + +setup_xcode_cloud_environment () { + # Return on failures + # Fail when expanding unset variables + # Trace each command before executing it + set -eEu + + # Move to the project root + cd .. + + # Prevent installing dependencies in system directories + echo 'export GEM_HOME=$HOME/.gem' >>~/.zshrc + echo 'export PATH=$GEM_HOME/bin:$PATH' >>~/.zshrc + echo 'export PATH="/usr/local/opt/ruby@2.7/bin:$PATH"' >> ~/.zshrc + echo 'export PATH="/Users/local/Library/Python/3.9/bin:$PATH"' >> ~/.zshrc + + export GEM_HOME=$HOME/.gem + export PATH=$GEM_HOME/bin:$PATH + export PATH="/usr/local/opt/ruby@2.7/bin:$PATH" + export PATH="/Users/local/Library/Python/3.9/bin:$PATH" + + # Things don't work well on the default ruby version + brew install ruby@2.7 + + gem install bundler + + bundle config path vendor/bundle + bundle install --jobs 4 --retry 3 +} + +install_xcode_cloud_brew_dependencies () { + brew update && brew install xcodegen imagemagick +} + +setup_github_actions_environment() { + brew update && brew install xcodegen git-lfs imagemagick + + bundle config path vendor/bundle + bundle install --jobs 4 --retry 3 + + pod install +} diff --git a/fastlane/Fastfile b/fastlane/Fastfile index aa059c588..0f4ba890a 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -13,6 +13,13 @@ # Uncomment the line if you want fastlane to automatically update itself # update_fastlane +before_all do + xcversion(version: "~> 14.3") + + ENV["FASTLANE_XCODEBUILD_SETTINGS_TIMEOUT"] = "180" + ENV["FASTLANE_XCODE_LIST_TIMEOUT"] = "180" +end + lane :linting do swiftlint( mode: :lint,