From 355693d38c96adeb39cd159e7847630a400eee57 Mon Sep 17 00:00:00 2001 From: FengZhang Date: Fri, 5 May 2023 00:28:12 +0800 Subject: [PATCH] feat: integrate test (#535) feat add integrate_test --- .github/workflows/integrate-test.yml | 74 ++++++++++++++++++++++++++++ integrate_test.sh | 48 ++++++++++++++++++ 2 files changed, 122 insertions(+) create mode 100644 .github/workflows/integrate-test.yml create mode 100644 integrate_test.sh diff --git a/.github/workflows/integrate-test.yml b/.github/workflows/integrate-test.yml new file mode 100644 index 00000000..880eb0d8 --- /dev/null +++ b/.github/workflows/integrate-test.yml @@ -0,0 +1,74 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +name: "integrate-test" + +on: + # Triggers the workflow on push or pull request events but only for the master branch + push: + branches: [ master ] + pull_request: + branches: "*" + +permissions: + contents: read + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "build" + test: + # The type of runner that the job will run on + name: test + runs-on: ubuntu-latest + strategy: + matrix: + golang: + - 1.18 + + steps: + + - name: "set up go" + uses: actions/setup-go@v3 + with: + go-version: 1.18 + + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - name: "checkout ${{ github.ref }}" + uses: actions/checkout@v3 + + - name: Cache dependencies + uses: actions/cache@v3 + with: + # Cache + path: ~/go/pkg/mod + # Cache key + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + # An ordered list of keys to use for restoring the cache if no cache hit occurred for key + restore-keys: | + ${{ runner.os }}-go- + + # This step only runs when the event type is a pull_request + - name: Integrate Test + if: ${{ github.event_name == 'pull_request' }} + run: | + chmod +x integrate_test.sh && [[ -n "${{github.event.pull_request.head.repo.full_name}}" ]] && [[ -n "${{github.event.pull_request.head.sha}}" ]] && [[ -n "${{github.base_ref}}" ]] && ./integrate_test.sh ${{github.event.pull_request.head.repo.full_name}} ${{github.event.pull_request.head.sha}} ${{github.base_ref}} + + # This step only runs when the event type is a push + - name: Integrate Test + if: ${{ github.event_name == 'push' }} + run: | + chmod +x integrate_test.sh && ./integrate_test.sh $GITHUB_REPOSITORY $GITHUB_SHA $GITHUB_BASE_REF \ No newline at end of file diff --git a/integrate_test.sh b/integrate_test.sh new file mode 100644 index 00000000..19062de3 --- /dev/null +++ b/integrate_test.sh @@ -0,0 +1,48 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#!/bin/bash + +set -e +set -x + +echo 'start integrate-test' + +# set root workspace +ROOT_DIR=$(pwd) +echo "integrate-test root work-space -> ${ROOT_DIR}" + +# show all github-env +echo "github current commit id -> $2" +echo "github pull request branch -> ${GITHUB_REF}" +echo "github pull request slug -> ${GITHUB_REPOSITORY}" +echo "github pull request repo slug -> ${GITHUB_REPOSITORY}" +echo "github pull request actor -> ${GITHUB_ACTOR}" +echo "github pull request repo param -> $1" +echo "github pull request base branch -> $3" +echo "github pull request head branch -> ${GITHUB_HEAD_REF}" + +echo "use seata-go-samples $3 branch for integration testing" +git clone https://github.com/seata/seata-go-samples samples && cd samples + +# update seata-go to current commit id + +go mod edit -replace=github.com/seata/seata-go=github.com/"$1"@"$2" + +go mod tidy + +# start integrate test +./start_integrate_test.sh