From 3e4c283b550ddf01c603f9ff52b49ac041324d83 Mon Sep 17 00:00:00 2001 From: Huy Nguyen Date: Fri, 3 Jan 2020 10:05:20 -0800 Subject: [PATCH] Lint podspec on all pull requests - We recently let a couple of issues slip through code review becase we don't lint our podspec on pull requests since the task takes too long (about half an hour). To prevent this from happening again, this PR adds 2 new CI jobs that lint default and other subspecs on all PRs. By splitting into 2 tasks, the impact on total CI time should be mitigated somewhat. There is still a master-only task that lint all subspecs as the last line of defense in case the 2 new tasks miss any. --- .github/workflows/ci-pull-requests-only.yml | 26 ++++++++++++++++++++ .github/workflows/ci.yml | 2 +- build.sh | 27 +++++++++++++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/ci-pull-requests-only.yml diff --git a/.github/workflows/ci-pull-requests-only.yml b/.github/workflows/ci-pull-requests-only.yml new file mode 100644 index 000000000..0aee87211 --- /dev/null +++ b/.github/workflows/ci-pull-requests-only.yml @@ -0,0 +1,26 @@ +name: CI (pull-requests-only jobs) + +on: + pull_request: + branches: + - master + +jobs: + buildsh: + env: + DEVELOPER_DIR: /Applications/Xcode_11.app/Contents/Developer + strategy: + matrix: + mode: [cocoapods-lint-default-subspecs, cocoapods-lint-other-subspecs] + include: + - mode: cocoapods-lint-default-subspecs + name: Verify that default subspecs lint + - mode: cocoapods-lint-other-subspecs + name: Verify that other subspecs lint + name: ${{ matrix.name }} + runs-on: macOS-latest + steps: + - name: Checkout the Git repository + uses: actions/checkout@v1 + - name: Run build script + run: ./build.sh ${{ matrix.mode }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 99e2d69ef..b4b26d585 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,4 +32,4 @@ jobs: - name: Checkout the Git repository uses: actions/checkout@v1 - name: Run build script - run: ./build.sh ${{ matrix.mode }} \ No newline at end of file + run: ./build.sh ${{ matrix.mode }} diff --git a/build.sh b/build.sh index 620c9f62b..9701dfb9c 100755 --- a/build.sh +++ b/build.sh @@ -56,6 +56,11 @@ function build_example { fi } +# Lint subspec +function lint_subspec { + set -o pipefail && pod env && pod lib lint --allow-warnings --subspec="$1" +} + function cleanup { # remove all Pods directories find . -name Pods -type d -exec rm -rf {} + @@ -216,6 +221,28 @@ cocoapods-lint|all) success="1" ;; +cocoapods-lint-default-subspecs) + echo "Verifying that default subspecs lint." + + for subspec in 'Core' 'PINRemoteImage' 'Video' 'MapKit' 'AssetsLibrary' 'Photos'; do + echo "Verifying that $subspec subspec lints." + + lint_subspec $subspec + done + success="1" + ;; + +cocoapods-lint-other-subspecs) + echo "Verifying that other subspecs lint." + + for subspec in 'IGListKit' 'Yoga' 'TextNode2'; do + echo "Verifying that $subspec subspec lints." + + lint_subspec $subspec + done + success="1" + ;; + carthage|all) echo "Verifying carthage works."