-
Notifications
You must be signed in to change notification settings - Fork 13
89 lines (84 loc) · 3.61 KB
/
runIntegration.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
name: Flyte Integration Suite
on:
pull_request:
branches:
- main
jobs:
build_images:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v2
with:
fetch-depth: 0
tags: true
token: ${{ secrets.FLYTE_BOT_PAT }}
- name: Log in to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ secrets.FLYTE_BOT_USERNAME }}
password: ${{ secrets.FLYTE_BOT_PAT }}
- name: Iterate through top level directories and build Docker images
env:
ACCESS_TOKEN: ${{ secrets.FLYTE_BOT_PAT }}
run: |
# Get the SHA of the base commit of the PR
base_sha=${{ github.event.pull_request.base.sha }}
special_tag=build-success-${{github.event.pull_request.number}}
# Get the list of changed files between the last commit and the current one
latest_tag=$(git tag -l $special_tag | sort -V | tail -n 1)
if [ -z "$latest_tag" ]; then
echo "no previous successful build tag exists"
# If no previous successful build tag exists, check all commits
changed_files=$(git diff --name-only $base_sha HEAD)
else
# Otherwise, check only the commits since the last successful build
echo "previous successful build tag exists"
changed_files=$(git diff --name-only $latest_tag HEAD)
fi
echo "Changed files: $changed_files"
for dir in *; do
if [ -f "$dir/{{cookiecutter.project_name}}/Dockerfile" ]; then
# Check if any of the changed files are in the current directory
if echo "$changed_files" | grep -q "^$dir/"; then
echo "Building and pushing Docker image for $dir"
docker build -f $dir/{{cookiecutter.project_name}}/Dockerfile -t ghcr.io/${{ github.repository }}:${dir}-pr-${{github.event.pull_request.number}} $dir/{{cookiecutter.project_name}}
docker push ghcr.io/${{ github.repository }}:${dir}-pr-${{github.event.pull_request.number}}
else
echo "Skipping $dir as it does not contain changes"
fi
else
echo "Skipping $dir as it does not contain a Dockerfile"
fi
done
if [ -z "$latest_tag" ]; then
echo "No previous successful build tag exists, so no need to delete it"
else
echo "Deleting last tag and replacing it with this one, since it was successful"
git tag -d $latest_tag
git push origin :refs/tags/$latest_tag
fi
git config user.name "GitHub Actions"
git config user.email "[email protected]"
git tag build-success-${{ github.event.pull_request.number }} HEAD
git push origin build-success-${{ github.event.pull_request.number }}
integration_tests:
needs: build_images
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v2
- name: Run integration tests
env:
host: ${{ secrets.FLYTE_HOST }}
client_id: ${{ secrets.FLYTE_CLIENT_ID }}
client_secret: ${{ secrets.FLYTE_CLIENT_SECRET }}
run: |
pip install -r requirements.txt
python integration.py \
--host $host \
--client_id $client_id \
--client_secret $client_secret \
--image_suffix pr-${{ github.event.pull_request.number }} \
--image_hostname ghcr.io/${{ github.repository }}