-
Notifications
You must be signed in to change notification settings - Fork 41
107 lines (89 loc) · 3.9 KB
/
test_daily_latest_submodule.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
name: "tidy3d-submodule-daily-tests"
on:
workflow_dispatch:
schedule:
- cron: '0 9 * * *' # Runs at 9am UK-time every day
jobs:
test-latest-submodules:
runs-on: ubuntu-latest
steps:
- name: Checkout repository with submodules
uses: actions/checkout@v4
with:
submodules: 'recursive'
# This fetches only a single branch by default, so additional fetch is needed
fetch-depth: 0 # Optionally, set to 0 to fetch all history for all branches and tags
- name: Initialize and update submodule
run: |
git submodule update --init --recursive
- name: Determine the latest pre/2.* branch
id: get_latest_pre_branch
run: |
# Fetch all branches
git fetch --all --quiet
# List all remote branches for debugging purposes
echo "Available branches:"
git branch -r
# List branches matching the pre/2.* pattern
BRANCHES=$(git branch -r | grep 'origin/pre/2\.' | sed 's|origin/||' | sort -V)
# Debugging: Print out the matched branches
echo "Matched branches with pre/2.* pattern:"
echo "$BRANCHES"
# Identify the latest branch
LATEST_BRANCH=$(echo "$BRANCHES" | tail -n 1)
# Set the latest branch as an environment variable
echo "LATEST_BRANCH=$LATEST_BRANCH" >> $GITHUB_ENV
echo "Latest pre/2.* branch is: $LATEST_BRANCH"
- name: Check submodules for multiple branches
shell: bash
run: |
BRANCHES=("develop" $LATEST_BRANCH) # Add your branches here
for BRANCH in "${BRANCHES[@]}"; do
echo "Analyzing branch: $BRANCH"
# Fetch all branches and tags
git fetch --all --verbose
# Checkout the branch
git checkout $BRANCH
NOTEBOOKS_PATH=docs/notebooks
FAQ_PATH=docs/faq
# Checking Notebooks submodule
echo "Checking $NOTEBOOKS_PATH for updates..."
cd $NOTEBOOKS_PATH
NOTEBOOKS_CURRENT_COMMIT=$(git rev-parse HEAD)
echo $(git fetch --all --verbose)
echo $(git remote get-url origin)
if git show-ref --verify refs/remotes/origin/$BRANCH; then
echo "Branch $BRANCH exists."
else
echo "::error::Branch $BRANCH does not exist on remote."
exit 1
fi
NOTEBOOKS_LATEST_COMMIT=$(git rev-parse refs/remotes/origin/${BRANCH})
echo "NOTEBOOKS_LATEST_COMMIT: $NOTEBOOKS_LATEST_COMMIT"
echo "NOTEBOOKS_CURRENT_COMMIT: $NOTEBOOKS_CURRENT_COMMIT"
cd ../..
if [ "$NOTEBOOKS_LATEST_COMMIT" != "$NOTEBOOKS_CURRENT_COMMIT" ]; then
echo "::error::Submodule $NOTEBOOKS_PATH is not up to date with the $BRANCH branch. Please update it."
exit 1
else
echo "Submodule $NOTEBOOKS_PATH is up to date with the $BRANCH branch."
fi
# Checking FAQs only on the develop branch
if [[ "$BRANCH" == "develop" ]]; then
echo "Checking $FAQ_PATH for updates..."
cd $FAQ_PATH
FAQ_CURRENT_COMMIT=$(git rev-parse HEAD)
echo $(git fetch --all --verbose)
echo $(git remote get-url origin)
FAQ_LATEST_COMMIT=$(git rev-parse refs/remotes/origin/develop)
echo "FAQ_LATEST_COMMIT: $FAQ_LATEST_COMMIT"
echo "FAQ_CURRENT_COMMIT: $FAQ_CURRENT_COMMIT"
cd ../..
if [ "$FAQ_LATEST_COMMIT" != "$FAQ_CURRENT_COMMIT" ]; then
echo "::error::Submodule $FAQ_PATH is not up to date. Please update it."
exit 1
else
echo "Submodule $FAQ_PATH is up to date."
fi
fi
done