From 9ef8dd78653048c1b7c0bcab8f58aedfab0a72e4 Mon Sep 17 00:00:00 2001 From: zfCode Date: Sat, 1 Apr 2023 14:54:59 +0800 Subject: [PATCH 1/5] 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 000000000..53473a7b3 --- /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: "*" + 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.19 + + steps: + + - name: "set up go" + uses: actions/setup-go@v3 + with: + go-version: 1.19 + + # 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 000000000..e3859628b --- /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 -b ftr/integrate_test https://github.com/Code-Fight/seata-go-samples.git 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 From e69864db9fb728a6cff59913f52e43d3da5f3894 Mon Sep 17 00:00:00 2001 From: zfCode Date: Sat, 1 Apr 2023 15:03:28 +0800 Subject: [PATCH 2/5] test --- .github/workflows/integrate-test.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/integrate-test.yml b/.github/workflows/integrate-test.yml index 53473a7b3..76cb99525 100644 --- a/.github/workflows/integrate-test.yml +++ b/.github/workflows/integrate-test.yml @@ -14,7 +14,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - name: "integrate-test" on: From a38f7a67fa80b4af3b4adaadaf1bcfc42ba43aa8 Mon Sep 17 00:00:00 2001 From: zfCode Date: Sat, 1 Apr 2023 17:06:29 +0800 Subject: [PATCH 3/5] fix config file --- .github/workflows/integrate-test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/integrate-test.yml b/.github/workflows/integrate-test.yml index 76cb99525..7d3ca0b4f 100644 --- a/.github/workflows/integrate-test.yml +++ b/.github/workflows/integrate-test.yml @@ -14,12 +14,13 @@ # 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: "*" + branches: [ master ] pull_request: branches: "*" From 05ecd220787706a668c315b645e87cf20d9878bc Mon Sep 17 00:00:00 2001 From: zfCode Date: Sat, 1 Apr 2023 17:08:47 +0800 Subject: [PATCH 4/5] fix sample url --- integrate_test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integrate_test.sh b/integrate_test.sh index e3859628b..3900e259d 100644 --- a/integrate_test.sh +++ b/integrate_test.sh @@ -36,7 +36,7 @@ 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 -b ftr/integrate_test https://github.com/Code-Fight/seata-go-samples.git samples && cd samples +git clone -b ftr/integrate_test https://github.com/seata/seata-go-samples samples && cd samples # update seata-go to current commit id From 3a1b4e9d6089350a1063b0f89befb083a407b723 Mon Sep 17 00:00:00 2001 From: zfCode Date: Sat, 8 Apr 2023 19:56:22 +0800 Subject: [PATCH 5/5] fix some bug --- .github/workflows/integrate-test.yml | 4 ++-- integrate_test.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/integrate-test.yml b/.github/workflows/integrate-test.yml index 7d3ca0b4f..880eb0d87 100644 --- a/.github/workflows/integrate-test.yml +++ b/.github/workflows/integrate-test.yml @@ -37,14 +37,14 @@ jobs: strategy: matrix: golang: - - 1.19 + - 1.18 steps: - name: "set up go" uses: actions/setup-go@v3 with: - go-version: 1.19 + go-version: 1.18 # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - name: "checkout ${{ github.ref }}" diff --git a/integrate_test.sh b/integrate_test.sh index 3900e259d..19062de3b 100644 --- a/integrate_test.sh +++ b/integrate_test.sh @@ -36,7 +36,7 @@ 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 -b ftr/integrate_test https://github.com/seata/seata-go-samples samples && cd samples +git clone https://github.com/seata/seata-go-samples samples && cd samples # update seata-go to current commit id