Skip to content

Commit 0fd8125

Browse files
authored
Merge branch 'main' into add/listen_protocols
2 parents 286ef35 + 6319eb3 commit 0fd8125

63 files changed

Lines changed: 2791 additions & 21 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/.lastcommsha

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
4586a000ce72d970be7cfaef0ae40371c1e80177
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: mdBook PR Preview
2+
3+
on:
4+
pull_request:
5+
types: [opened, reopened, synchronize, closed]
6+
paths:
7+
- "docs/**"
8+
- ".github/workflows/preview-mdbook.yml"
9+
10+
permissions:
11+
contents: write
12+
pull-requests: write
13+
14+
concurrency: preview-${{ github.ref }}
15+
16+
jobs:
17+
deploy-preview:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- name: Install mdBook
23+
run: cargo install mdbook
24+
25+
- name: Build mdBook
26+
run: mdbook build docs
27+
28+
- name: Deploy PR Preview
29+
uses: rossjrw/pr-preview-action@v1.4.7
30+
with:
31+
source-dir: docs/book
32+
umbrella-dir: docs/pr-preview
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Documentation Deploy
2+
3+
on:
4+
# When a PR is merged (or force push to main)
5+
push:
6+
branches: ["main"]
7+
# Allows you to run this workflow manually from the Actions tab
8+
workflow_dispatch:
9+
10+
# Enable cargo logs to be in colour
11+
env:
12+
CARGO_TERM_COLOR: always
13+
14+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
15+
permissions:
16+
contents: write
17+
18+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
19+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
20+
concurrency:
21+
group: "pages"
22+
cancel-in-progress: false
23+
24+
jobs:
25+
build-mdbook:
26+
name: Build and Deploy mdBook
27+
environment:
28+
name: github-pages
29+
runs-on: ubuntu-latest
30+
steps:
31+
- uses: actions/checkout@v4
32+
33+
- name: Install mdBook
34+
run: cargo install mdbook --locked
35+
36+
- name: Build the book
37+
run: mdbook build docs
38+
39+
- name: Deploy to GitHub Pages
40+
uses: peaceiris/actions-gh-pages@v4.0.0
41+
with:
42+
github_token: ${{ secrets.GITHUB_TOKEN }}
43+
publish_dir: ./docs/book
44+
publish_branch: gh-pages
45+
destination_dir: ./main/
Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
name: issue-builder
2+
3+
on:
4+
schedule:
5+
- cron: '00 11 * * *'
6+
push:
7+
paths:
8+
- .github/.lastcommsha
9+
10+
workflow_dispatch:
11+
12+
jobs:
13+
check:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
issues: write
17+
contents: read
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v2
21+
- name: Check for 'tock-tbf' updates
22+
run: |
23+
TARGET_FILE="libraries/tock-tbf"
24+
25+
RESPONSE=$(curl -s "https://api.github.com/repos/${UPSTREAM}/commits?path=$TARGET_FILE&sha=master")
26+
27+
# Find sha of last commit
28+
COMMIT_SHA=$(echo "$RESPONSE" | jq -r ".[0].sha")
29+
echo "Commit sha: $COMMIT_SHA"
30+
31+
# Find sha stored in file
32+
SHA_RESPONSE=$(curl -s -L \
33+
-H "Accept: application/vnd.github+json" \
34+
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
35+
-H "X-GitHub-Api-Version: 2022-11-28" \
36+
https://api.github.com/repos/${DOWNSTREAM}/contents/.github/.lastcommsha)
37+
38+
STORED_SHA=$(echo "$SHA_RESPONSE" | jq -r '.content' | base64 -d | tr -d '\n')
39+
echo "Last stored SHA: $STORED_SHA"
40+
41+
# Check if provided sha is valid
42+
NUM_COMMITS=$(echo "$RESPONSE" | jq length)
43+
FOUND=0
44+
45+
for (( i=0; i<NUM_COMMITS; i++ )); do
46+
CURR_COMM_SHA=$(echo "$RESPONSE" | jq -r ".[$i].sha")
47+
if [ "$CURR_COMM_SHA" == "$STORED_SHA" ]; then
48+
FOUND=1
49+
break
50+
fi
51+
done
52+
53+
if [ "$FOUND" -eq 0 ]; then
54+
echo "Invalid SHA. Please double-check it."
55+
exit 1
56+
fi
57+
58+
# Check if the two shas match to check if we're up to date
59+
if [ "$COMMIT_SHA" == "$STORED_SHA" ]; then
60+
echo "Up to date."
61+
# Since we're up to date => close existing issue if open
62+
63+
# Get existing issue
64+
mapfile -t matching_open_issues < <(gh issue list \
65+
--label "$LABELS" \
66+
--state open \
67+
--json number,title \
68+
--jq ".[] | select(.title == \"$TITLE\") | .number")
69+
70+
# If open issue is found => close
71+
if (( ${#matching_open_issues[@]} != 0 )); then
72+
for issue_number in "${matching_open_issues[@]}"; do
73+
echo "Closing issue..."
74+
gh issue close "$issue_number"
75+
done
76+
fi
77+
78+
exit 0
79+
else
80+
echo "Different - must update"
81+
82+
i=0
83+
COMM_SHAS=()
84+
COMM_MSGS=()
85+
86+
# Build array of shas that need to be listed in the issue
87+
for (( i=0; i<NUM_COMMITS; i++ )); do
88+
CURR_COMM_SHA=$(echo "$RESPONSE" | jq -r ".[$i].sha")
89+
CURR_COMM_MSG=$(echo "$RESPONSE" | jq -r ".[$i].commit.message")
90+
91+
if [ "$CURR_COMM_SHA" == "$STORED_SHA" ]; then
92+
break
93+
fi
94+
95+
COMM_SHAS+=("$CURR_COMM_SHA")
96+
COMM_MSGS+=("$CURR_COMM_MSG")
97+
done
98+
99+
# Debug echo for array
100+
for idx in "${!COMM_SHAS[@]}"; do
101+
echo "sha $idx is ${COMM_SHAS[$idx]}"
102+
done
103+
for idx in "${!COMM_MSGS[@]}"; do
104+
echo "sha $idx is ${COMM_MSGS[$idx]}"
105+
done
106+
107+
# Make commit markdown list
108+
COMMIT_LIST=""
109+
for idx in "${!COMM_SHAS[@]}"; do
110+
short_sha=$(git rev-parse --short "${COMM_SHAS[$idx]}")
111+
url="https://github.com/${UPSTREAM}/commit/${COMM_SHAS[$idx]}"
112+
message="$(echo "${COMM_MSGS[$idx]}" | head -n1)"
113+
COMMIT_LIST+="- [\`$short_sha\`]($url): $message"$'\n'
114+
done
115+
116+
# Get matching issues
117+
mapfile -t matching_issues < <(gh issue list \
118+
--label "$LABELS" \
119+
--state all \
120+
--json number,title \
121+
--jq ".[] | select(.title == \"$TITLE\") | .number")
122+
123+
# Check if issue already exists
124+
if (( ${#matching_issues[@]} == 0 )); then
125+
# Doesn't exist => new issue creation
126+
echo "New issue creation"
127+
new_issue_url=$(gh issue create \
128+
--title "$TITLE" \
129+
--label "$LABELS" \
130+
--body "$BODY"$'\n'"$COMMIT_LIST")
131+
if [[ $PINNED == true ]]; then
132+
gh issue pin "$new_issue_url"
133+
fi
134+
else
135+
# Exists => edit existing issue
136+
# Check if issue is closed in order to open it
137+
for issue_number in "${matching_issues[@]}"; do
138+
ISSUE_STATE=$(gh api repos/${DOWNSTREAM}/issues/"$issue_number" --jq '.state')
139+
if [[ "$ISSUE_STATE" == "closed" ]]; then
140+
echo "Issue closed. Reopening..."
141+
gh issue reopen "$issue_number"
142+
fi
143+
done
144+
145+
echo "Issue already exists; editting and commenting on issue"
146+
for issue_number in "${matching_issues[@]}"; do
147+
# Extract commit body for comparison
148+
ISSUE_BODY=$(gh api repos/${DOWNSTREAM}/issues/"$issue_number" --jq '.body')
149+
# Compare old list with new list
150+
# Check for changes between new list and old list
151+
# Debug echoes for body comparison
152+
echo "Old issue body: $ISSUE_BODY"
153+
echo "New issue body: $BODY"$'\n'"$COMMIT_LIST"
154+
if [[ "$ISSUE_BODY"$'\n' != "$BODY"$'\n'"$COMMIT_LIST" ]]; then
155+
echo "Bodies different => edit comment"
156+
gh issue comment "$issue_number" \
157+
--edit-last --create-if-none\
158+
--body "Commits list updated."
159+
else
160+
echo "Bodies same => no comment"
161+
fi
162+
gh issue edit "$issue_number" \
163+
--body "$BODY"$'\n'"$COMMIT_LIST"
164+
done
165+
fi
166+
167+
exit 0
168+
fi
169+
env:
170+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
171+
GH_REPO: ${{ github.repository }}
172+
UPSTREAM: "tock/tock"
173+
DOWNSTREAM: "WyliodrinEmbeddedIoT/tockloader-rs"
174+
TITLE: Bring updates from 'tock-tbf' to 'tbf-parser'
175+
LABELS: D3-TBF PARSER,P1-CRITICAL,EXCLUSIVE LABEL
176+
BODY: |
177+
Please review the commits in order of oldest to newest (top to bottom). Once you have implemented the corresponding updates, copy-paste the sha of the commit you last covered in ['.lastcommsha'](https://github.com/WyliodrinEmbeddedIoT/tockloader-rs/tree/main/.github/.lastcommsha). Make sure to label any PRs addressing the commits in this list with 'EXCLUSIVE LABEL'. The following commits need to be accounted for:
178+
PINNED: false
179+
CLOSE_PREVIOUS: true
180+
181+
182+

.github/workflows/rust.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,20 @@ jobs:
2121
- uses: actions/checkout@v3
2222
- name: Install libudev
2323
run: sudo apt-get install -y libudev-dev
24+
- name: Tauri dependencies
25+
run: |
26+
sudo apt update && sudo apt install -y \
27+
libwebkit2gtk-4.1-dev \
28+
build-essential \
29+
curl \
30+
wget \
31+
file \
32+
libxdo-dev \
33+
libssl-dev \
34+
libayatana-appindicator3-dev \
35+
librsvg2-dev \
36+
webkit2gtk-driver \
37+
xvfb
2438
- name: Build
2539
run: cargo build --verbose
2640
- name: Run tests
@@ -49,5 +63,19 @@ jobs:
4963
components: clippy
5064
- name: Install libudev
5165
run: sudo apt-get install -y libudev-dev
66+
- name: Tauri dependencies
67+
run: |
68+
sudo apt update && sudo apt install -y \
69+
libwebkit2gtk-4.1-dev \
70+
build-essential \
71+
curl \
72+
wget \
73+
file \
74+
libxdo-dev \
75+
libssl-dev \
76+
libayatana-appindicator3-dev \
77+
librsvg2-dev \
78+
webkit2gtk-driver \
79+
xvfb
5280
- name: ci-job-clippy
5381
run: make ci-job-clippy

.github/workflows/sha-checker.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: sha-checker
2+
3+
on:
4+
pull_request:
5+
types: [labeled, unlabeled, opened, reopened, synchronize]
6+
workflow_dispatch:
7+
jobs:
8+
check:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: read
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v2
15+
- name: Check if files included in appropriately labeled PRs
16+
run: |
17+
# Get PR number
18+
PR_NO=$(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH")
19+
echo "PR number: $PR_NO"
20+
21+
# Get PR labels
22+
labels="$(gh api repos/${DOWNSTREAM}/pulls/$PR_NO --jq '.labels.[].name')"
23+
echo "$labels"
24+
25+
# Check for exclusive label to continue operations
26+
if [[ $labels =~ (EXCLUSIVE LABEL) ]]; then
27+
echo "Label found. Continuing..."
28+
else
29+
echo "Label not found. No sha-checker needed."
30+
exit 0
31+
fi
32+
33+
# Get changed files
34+
files="$(gh pr view "$PR_NO" --json files -q '.files[].path')"
35+
echo "$files"
36+
37+
# Check if '.lastcommsha' among changed files
38+
if [[ $files =~ (.lastcommsha) ]]; then
39+
echo "File found."
40+
exit 0
41+
else
42+
echo "File not found. Please make sure you update the sha within '.lastcommsha'."
43+
exit 1
44+
fi
45+
46+
env:
47+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48+
UPSTREAM: "tock/tock"
49+
DOWNSTREAM: "WyliodrinEmbeddedIoT/tockloader-rs"
50+
51+

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44

55
[workspace]
66

7-
resolver = "2"
7+
resolver= "3"
88

99
members = [
1010
"tockloader-cli",
1111
"tock-process-console",
1212
"tbf-parser",
1313
"tockloader-lib",
14+
"tock-ui/src-tauri",
1415
]

0 commit comments

Comments
 (0)