@@ -21,22 +21,28 @@ permissions:
2121jobs :
2222 build-and-test :
2323 runs-on : ubuntu-latest
24- defaults :
25- run :
26- working-directory : ${{ env.WORK_DIR }}
2724 environment : test
2825 steps :
2926 - name : Checkout repository
3027 uses : actions/checkout@v3
3128 with :
32- fetch-depth : 0
29+ ref : ${{ github.event.pull_request.base.ref }}
30+ repository : ${{ github.repository }}
3331
34- - name : Check spelling of repo
35- uses : crate-ci/typos@master
32+ - name : Checkout forked repository
33+ uses : actions/checkout@v3
34+ with :
35+ ref : ${{ github.event.pull_request.head.ref }}
36+ repository : ${{ github.event.pull_request.head.repo.full_name }}
37+ path : fork
38+
39+ - name : Set working directory
40+ run : echo "WORKING_DIRECTORY=fork/${{ env.WORK_DIR }}" >> $GITHUB_ENV
3641
3742 - name : Get list of changed files
3843 id : files
3944 run : |
45+ cd ${{ env.WORKING_DIRECTORY }}
4046 git fetch origen +${{ github.event.pull_request.base.sha }}:refs/remotes/origen/pr-base +${{ github.event.pull_request.head.sha }}:refs/remotes/origen/pr-head
4147 git diff --name-only origen/pr-base origen/pr-head > /tmp/changed_files.txt
4248 echo "CHANGED_FILES<<EOF" >> $GITHUB_ENV
@@ -45,10 +51,13 @@ jobs:
4551 echo "::set-output name=changed_files::$(cat /tmp/changed_files.txt)"
4652
4753 - name : Set short SHA for image tag
48- run : echo "IMAGE_TAG=$(echo ${{ github.sha }} | cut -c 1-7)" >> $GITHUB_ENV
54+ run : |
55+ cd ${{ env.WORKING_DIRECTORY }}
56+ echo "IMAGE_TAG=$(echo ${{ github.sha }} | cut -c 1-7)" >> $GITHUB_ENV
4957
5058 - name : Check for git tag version
5159 run : |
60+ cd ${{ env.WORKING_DIRECTORY }}
5261 TAG=$(git describe --tags --exact-match 2> /dev/null || echo "")
5362 if [[ -n "$TAG" ]]; then
5463 echo "IMAGE_TAG=${TAG}" >> $GITHUB_ENV
@@ -60,10 +69,13 @@ jobs:
6069 python-version : 3.x
6170
6271 - name : Install Dependencies
63- run : pip install -r requirements.txt
72+ run : |
73+ cd ${{ env.WORKING_DIRECTORY }}
74+ pip install -r requirements.txt
6475
6576 - name : Build Docker image
6677 run : |
78+ cd ${{ env.WORKING_DIRECTORY }}
6779 docker build -t taskingai/taskingai-plugin:$IMAGE_TAG .
6880 echo "Build success: taskingai/taskingai-plugin:${IMAGE_TAG}"
6981
7385 AES_ENCRYPTION_KEY : ${{ env.AES_ENCRYPTION_KEY }}
7486 TEST_S3_SECRET_R2 : ${{ secrets.TEST_S3_SECRET_R2 }}
7587 run : |
88+ cd ${{ env.WORKING_DIRECTORY }}
7689 echo "$PLUGIN_BUNDLE_CREDENTIALS" > .env
7790 echo "$TEST_S3_SECRET_R2" >> .env
7891 docker run -d --name test_container --network=host \
@@ -86,16 +99,19 @@ jobs:
8699
87100 - name : Run Tests
88101 run : |
102+ cd ${{ env.WORKING_DIRECTORY }}
89103 bash ./test/run_test.sh /tmp/changed_files.txt
90104
91105 - name : Run Local Tests
92106 run : |
107+ cd ${{ env.WORKING_DIRECTORY }}
93108 export PATH_TO_VOLUME=./test
94109 export HOST_URL=http://localhost:8030
95110 bash ./test/run_local_test.sh
96111
97112 - name : Stop Docker container
98113 run : |
114+ cd ${{ env.WORKING_DIRECTORY }}
99115 docker stop test_container
100116 sleep 5
101117
@@ -105,6 +121,7 @@ jobs:
105121 AES_ENCRYPTION_KEY : ${{ env.AES_ENCRYPTION_KEY }}
106122 TEST_S3_SECRET_AWS : ${{ secrets.TEST_S3_SECRET_AWS }}
107123 run : |
124+ cd ${{ env.WORKING_DIRECTORY }}
108125 echo "$PLUGIN_BUNDLE_CREDENTIALS" > 1.env
109126 echo "$TEST_S3_SECRET_AWS" >> 1.env
110127 docker run -d --name aws_s3_docker --network=host \
@@ -118,11 +135,13 @@ jobs:
118135
119136 - name : Run S3 without public domain Tests
120137 run : |
138+ cd ${{ env.WORKING_DIRECTORY }}
121139 echo "$TEST_S3_SECRET_AWS" > .env
122140 bash ./test/run_s3_without_test.sh
123141
124142 - name : Stop Docker container
125143 run : |
144+ cd ${{ env.WORKING_DIRECTORY }}
126145 docker stop aws_s3_docker
127146 sleep 5
128147
@@ -132,6 +151,7 @@ jobs:
132151 AES_ENCRYPTION_KEY : ${{ env.AES_ENCRYPTION_KEY }}
133152 TEST_S3_SECRET_R2 : ${{ secrets.TEST_S3_SECRET_R2 }}
134153 run : |
154+ cd ${{ env.WORKING_DIRECTORY }}
135155 echo "$PLUGIN_BUNDLE_CREDENTIALS" > 2.env
136156 echo "$TEST_S3_SECRET_R2" >> 2.env
137157 docker run -d --name r2_docker --network=host \
@@ -145,10 +165,12 @@ jobs:
145165
146166 - name : Run S3 with public domain Tests
147167 run : |
168+ cd ${{ env.WORKING_DIRECTORY }}
148169 echo "$TEST_S3_SECRET_R2" > .env
149170 bash ./test/run_s3_with_test.sh
150171
151172 - name : Stop Docker container
152173 run : |
174+ cd ${{ env.WORKING_DIRECTORY }}
153175 docker stop r2_docker
154176 sleep 5
0 commit comments