Skip to content

Commit 355693d

Browse files
authored
feat: integrate test (apache#535)
feat add integrate_test
1 parent 0e4876e commit 355693d

File tree

2 files changed

+122
-0
lines changed

2 files changed

+122
-0
lines changed

.github/workflows/integrate-test.yml

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
name: "integrate-test"
19+
20+
on:
21+
# Triggers the workflow on push or pull request events but only for the master branch
22+
push:
23+
branches: [ master ]
24+
pull_request:
25+
branches: "*"
26+
27+
permissions:
28+
contents: read
29+
30+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
31+
jobs:
32+
# This workflow contains a single job called "build"
33+
test:
34+
# The type of runner that the job will run on
35+
name: test
36+
runs-on: ubuntu-latest
37+
strategy:
38+
matrix:
39+
golang:
40+
- 1.18
41+
42+
steps:
43+
44+
- name: "set up go"
45+
uses: actions/setup-go@v3
46+
with:
47+
go-version: 1.18
48+
49+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
50+
- name: "checkout ${{ github.ref }}"
51+
uses: actions/checkout@v3
52+
53+
- name: Cache dependencies
54+
uses: actions/cache@v3
55+
with:
56+
# Cache
57+
path: ~/go/pkg/mod
58+
# Cache key
59+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
60+
# An ordered list of keys to use for restoring the cache if no cache hit occurred for key
61+
restore-keys: |
62+
${{ runner.os }}-go-
63+
64+
# This step only runs when the event type is a pull_request
65+
- name: Integrate Test
66+
if: ${{ github.event_name == 'pull_request' }}
67+
run: |
68+
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}}
69+
70+
# This step only runs when the event type is a push
71+
- name: Integrate Test
72+
if: ${{ github.event_name == 'push' }}
73+
run: |
74+
chmod +x integrate_test.sh && ./integrate_test.sh $GITHUB_REPOSITORY $GITHUB_SHA $GITHUB_BASE_REF

integrate_test.sh

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
#!/bin/bash
18+
19+
set -e
20+
set -x
21+
22+
echo 'start integrate-test'
23+
24+
# set root workspace
25+
ROOT_DIR=$(pwd)
26+
echo "integrate-test root work-space -> ${ROOT_DIR}"
27+
28+
# show all github-env
29+
echo "github current commit id -> $2"
30+
echo "github pull request branch -> ${GITHUB_REF}"
31+
echo "github pull request slug -> ${GITHUB_REPOSITORY}"
32+
echo "github pull request repo slug -> ${GITHUB_REPOSITORY}"
33+
echo "github pull request actor -> ${GITHUB_ACTOR}"
34+
echo "github pull request repo param -> $1"
35+
echo "github pull request base branch -> $3"
36+
echo "github pull request head branch -> ${GITHUB_HEAD_REF}"
37+
38+
echo "use seata-go-samples $3 branch for integration testing"
39+
git clone https://github.com/seata/seata-go-samples samples && cd samples
40+
41+
# update seata-go to current commit id
42+
43+
go mod edit -replace=github.com/seata/seata-go=github.com/"$1"@"$2"
44+
45+
go mod tidy
46+
47+
# start integrate test
48+
./start_integrate_test.sh

0 commit comments

Comments
 (0)