-
Notifications
You must be signed in to change notification settings - Fork 3
118 lines (99 loc) · 4.41 KB
/
run_jcb_basic_testing.yaml
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
name: Run JCB client testing with client changes
on:
push:
branches:
- develop
pull_request:
types:
- opened
- synchronize
- reopened
jobs:
jcb_integration_tests:
runs-on: ubuntu-latest
name: JCB Client Integration Tests
env:
JCB_REPO: https://github.com/NOAA-EMC/jcb.git
steps:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Add repo url to the environment
run: |
JCB_APP_REPO="${{ github.repository }}"
echo "JCB_APP_REPO=${JCB_APP_REPO}" >> $GITHUB_ENV
- name: Determine the name of the client branch
run: |
if [ "${{ github.event_name }}" == "pull_request" ]; then
JCB_APP_BRANCH=${{ github.head_ref }}
else
BRANCH_REF=${{ github.ref }}
JCB_APP_BRANCH=${BRANCH_REF#refs/heads/}
fi
echo "JCB_APP_BRANCH=$JCB_APP_BRANCH" >> $GITHUB_ENV
- name: Determine branch to use for main jcb repo
run: |
BRANCH_NAME=${{ env.JCB_APP_BRANCH }}
if git ls-remote --heads $JCB_REPO $BRANCH_NAME | grep -q "refs/heads/$BRANCH_NAME"; then
echo "Branch $BRANCH_NAME exists in jcb repo."
echo "JCB_BRANCH=$BRANCH_NAME" >> $GITHUB_ENV
else
echo "Branch $BRANCH_NAME does not exist in jcb repo. Using develop branch."
echo "JCB_BRANCH=develop" >> $GITHUB_ENV
fi
- name: Check for the branch name in the jcb-algorithms repo (if not develop)
run: |
BRANCH_NAME=${{ env.JCB_APP_BRANCH }}
# If branch name is develop then we don't need to check the jcb-algorithms repo.
if [ "$BRANCH_NAME" == "develop" ]; then
echo "JCB_ALGO_BRANCH=develop" >> $GITHUB_ENV
exit 0
fi
# If the branch is not develop then check the jcb-algorithms repo.
if git ls-remote --heads https://github.com/NOAA-EMC/jcb-algorithms.git $BRANCH_NAME | grep -q "refs/heads/$BRANCH_NAME"; then
echo "Branch $BRANCH_NAME exists in jcb-algorithms repo."
echo "JCB_ALGO_BRANCH=$BRANCH_NAME" >> $GITHUB_ENV
# If the branch exists in jcb-algorithms repo but JCB_BRANCH is develop then we need to
# throw an error. This is not a safe situation. The developer should create a branch in
# the main jcb repo with the same name as the branch in the jcb-application repo.
# If there were branches in other apps to account for the changes in the algorithm repo
# they could not be tested here since the scipt is not clever enough to check for
# the existence of the branch being tested here in all the clients. The safest thing to do
# is simply create a branch with the same name (even if empty) in the main jcb repo. This
# will ensure the branches of the other applications are checked out by the init script.
if [ "${{ env.JCB_BRANCH }}" == "develop" ]; then
echo "Branch $BRANCH_NAME exists in jcb-algorithms repo but not in the main jcb repo. "
echo "Please create a branch with the same name (even if empty with no PR) in the main "
echo "jcb repo. This ensures safely checking all the clients that depend on the "
echo "jcb and jcb-algorithms repos with the changes being proposed."
exit 1
fi
fi
- name: Clone jcb repository
run: |
mkdir -p empty_hooks
git config --global core.hooksPath empty_hooks
git clone --branch ${{ env.JCB_BRANCH }} --recursive $JCB_REPO jcb_repo
- name: Clone the clients
run: |
cd jcb_repo
pip install pyyaml
./jcb_client_init.py
# If all the branches are found then at this point everything should be good since
# jcb_client_init will check out the correct branches. If not then the app branch needs to
# be checked out explicitly.
if [ "${{ env.JCB_BRANCH }}" != "${{ env.JCB_APP_BRANCH }}" ]; then
echo "Checking out branch ${{ env.JCB_APP_BRANCH }} for ${{ env.JCB_APP_REPO }}"
app_path=$(python jcb_client_path.py $JCB_APP_REPO)
cd $app_path
git checkout ${{ env.JCB_APP_BRANCH }}
fi
- name: Install dependencies
run: |
cd jcb_repo
pip install .[testing]
- name: Run the JCB client integration tests
run: |
cd jcb_repo/test/client_integration
pytest -v