diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index a819474..a19cb3e 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -2,6 +2,9 @@ name: Publish CocoaPods package on: release: types: [created] +env: + NODE_FILENAME: node-template-x86_64-apple-darwin.tar.gz + NODE_BIN: node-template jobs: publish: runs-on: macOS-13 @@ -14,17 +17,38 @@ jobs: run: sed -i '' "s|[[:blank:]]*s\.version[[:blank:]].*|s.version = '${VERSION}'|g" *.podspec env: VERSION: ${{ github.event.release.tag_name }} + - name: Get node version + id: node-version + run: echo "VERSION=$(cat Tests/node-version.txt)" >> "$GITHUB_OUTPUT" + - name: Download Substrate Node + uses: dsaltares/fetch-gh-release-asset@1.1.1 + with: + repo: 'substrate-developer-hub/substrate-node-template' + version: 'tags/${{ steps.node-version.outputs.VERSION }}' + file: ${{ env.NODE_FILENAME }} + - name: Unpack Substrate Node + run: tar -xvzf ${{ env.NODE_FILENAME }} - name: Update CocoaPods repo run: pod repo update - name: Publish Substrate Pod run: pod trunk push --allow-warnings --synchronous Substrate.podspec env: COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }} - - name: Publish RPC Pod - run: pod trunk push --allow-warnings --synchronous Substrate-RPC.podspec - env: - COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }} - name: Publish Keychain Pod run: pod trunk push --allow-warnings --synchronous Substrate-Keychain.podspec env: COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }} + - name: Publish RPC Pod + env: + COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }} + run: | + Tests/with-node.sh './${{ env.NODE_BIN }}' \ + 'pod trunk push --allow-warnings --synchronous Substrate-RPC.podspec' \ + 'node_log.txt' + - name: Upload node log + uses: actions/upload-artifact@v3 + with: + name: test_node_full_log.txt + path: node_log.txt + + diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e417598..eb5f3a9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,7 +1,9 @@ name: Build & Tests on: [push, pull_request] env: - SUBSTRATE_NODE_VERSION: 'v0.9.40' + NODE_FILENAME_MAC: node-template-x86_64-apple-darwin.tar.gz + NODE_FILENAME_LINUX: node-template-x86_64-unknown-linux-gnu.tar.gz + NODE_BIN: node-template jobs: apple: strategy: @@ -20,27 +22,48 @@ jobs: uses: actions/checkout@v3 - name: Select Xcode run: sudo xcode-select -s /Applications/Xcode_${{ matrix.tests.xcode }}.app + - name: Get node version + id: node-version + run: echo "VERSION=$(cat Tests/node-version.txt)" >> "$GITHUB_OUTPUT" - name: Download Substrate Node uses: dsaltares/fetch-gh-release-asset@1.1.1 with: repo: 'substrate-developer-hub/substrate-node-template' - version: 'tags/${{ env.SUBSTRATE_NODE_VERSION }}' - file: 'node-template-x86_64-apple-darwin.tar.gz' + version: 'tags/${{ steps.node-version.outputs.VERSION }}' + file: ${{ env.NODE_FILENAME_MAC }} - name: Unpack Substrate Node - run: tar -xvzf *.tar.gz + run: tar -xvzf ${{ env.NODE_FILENAME_MAC }} - name: Build & Test SPM - run: ./run_with_node.sh './node-template' 'xcrun swift test' 'node_log.txt' + run: Tests/with-node.sh './${{env.NODE_BIN}}' 'xcrun swift test' 'node_log.txt' - name: Upload swift test node log uses: actions/upload-artifact@v3 with: name: swift_test_node_full_log.txt path: node_log.txt + - name: Cocoapods Repo Update + run: pod repo update - name: Substrate Build & Test Cocoapods - run: pod repo update && pod lib lint --allow-warnings --fail-fast Substrate.podspec + run: | + pod lib lint --allow-warnings --fail-fast Substrate.podspec + # save podspec to env + echo "LINTED_PODS=Substrate.podspec" >> "$GITHUB_ENV" - name: Keychain Build & Test Cocoapods - run: pod lib lint --allow-warnings --fail-fast --include-podspecs=Substrate.podspec Substrate-Keychain.podspec + run: | + pod lib lint --allow-warnings --fail-fast \ + --include-podspecs="{${LINTED_PODS}}" Substrate-Keychain.podspec + # save podspec to env + echo "LINTED_PODS=${LINTED_PODS},Substrate-Keychain.podspec" >> "$GITHUB_ENV" - name: RPC Build & Test Cocoapods - run: pod lib lint --allow-warnings --fail-fast --include-podspecs=Substrate.podspec Substrate-RPC.podspec + run: | + Tests/with-node.sh './${{env.NODE_BIN}}' \ + 'pod lib lint --allow-warnings --fail-fast \ + --include-podspecs="{${LINTED_PODS}}" Substrate-RPC.podspec' \ + 'cp_node_log.txt' + - name: Upload swift test node log + uses: actions/upload-artifact@v3 + with: + name: cocoapods_node_full_log.txt + path: cp_node_log.txt linux: strategy: matrix: @@ -55,16 +78,19 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 + - name: Get node version + id: node-version + run: echo "VERSION=$(cat Tests/node-version.txt)" >> "$GITHUB_OUTPUT" - name: Download Substrate Node uses: dsaltares/fetch-gh-release-asset@1.1.1 with: repo: 'substrate-developer-hub/substrate-node-template' - version: 'tags/${{ env.SUBSTRATE_NODE_VERSION }}' - file: 'node-template-x86_64-unknown-linux-gnu.tar.gz ' + version: 'tags/${{ steps.node-version.outputs.VERSION }}' + file: ${{ env.NODE_FILENAME_LINUX }} - name: Unpack Substrate Node - run: tar -xvzf *.tar.gz + run: tar -xvzf ${{ env.NODE_FILENAME_LINUX }} - name: Build and Test - run: ./run_with_node.sh './node-template' 'swift test' 'node_log.txt' + run: Tests/with-node.sh './${{env.NODE_BIN}}' 'swift test' 'node_log.txt' - name: Upload node log uses: actions/upload-artifact@v3 with: diff --git a/Substrate-RPC.podspec b/Substrate-RPC.podspec index 8e7a8e6..d56557c 100644 --- a/Substrate-RPC.podspec +++ b/Substrate-RPC.podspec @@ -18,4 +18,10 @@ Pod::Spec.new do |s| s.dependency 'Substrate', "#{s.version}" s.dependency 'JsonRPC.swift', '~> 0.2.3' s.dependency 'Serializable.swift', '~> 0.3.1' + + s.test_spec 'IntegrationTests' do |ts| + ts.platforms = base_platforms + ts.depencency 'Substrate-Keychain', "#{s.version}" + ts.source_files = 'Tests/IntegrationTests/**/*.swift' + end end diff --git a/Tests/node-version.txt b/Tests/node-version.txt new file mode 100644 index 0000000..0cadb4e --- /dev/null +++ b/Tests/node-version.txt @@ -0,0 +1 @@ +v0.9.40 \ No newline at end of file diff --git a/run_with_node.sh b/Tests/with-node.sh similarity index 100% rename from run_with_node.sh rename to Tests/with-node.sh