Skip to content

Commit 50c82f7

Browse files
Update CMake and release workflow
1 parent bd73238 commit 50c82f7

4 files changed

Lines changed: 33 additions & 187 deletions

File tree

.github/workflows/release.yml

Lines changed: 18 additions & 186 deletions
Original file line numberDiff line numberDiff line change
@@ -1,198 +1,30 @@
11
name: Release automation
22

3+
permissions:
4+
contents: write
5+
pull-requests: write
6+
37
on:
48
workflow_dispatch:
59
inputs:
6-
commit_id:
7-
description: 'Commit ID to tag and create a release for'
8-
required: true
910
version_number:
1011
description: 'Release Version Number (Eg, v1.0.0)'
1112
required: true
12-
13-
# Workflow permissions block
14-
permissions:
15-
contents: write # This grants write access to repository content, including pushing commits/tags and creating releases.
13+
branch:
14+
description: 'Branch to release from'
15+
required: false
16+
default: 'main'
1617

1718
jobs:
18-
tag-commit:
19-
name: Tag commit
20-
runs-on: ubuntu-latest
21-
steps:
22-
- name: Checkout code
23-
uses: actions/checkout@v4
24-
with:
25-
ref: ${{ github.event.inputs.commit_id }}
26-
- name: Configure git identity
27-
env:
28-
ACTOR: ${{ github.actor }}
29-
run: |
30-
git config --global user.name "$ACTOR"
31-
git config --global user.email "$ACTOR"@users.noreply.github.com
32-
- name: create a new branch that references commit id
33-
env:
34-
VERSION_NUMBER: ${{ github.event.inputs.version_number }}
35-
COMMIT_ID: ${{ github.event.inputs.commit_id }}
36-
run: git checkout -b "$VERSION_NUMBER" "$COMMIT_ID"
37-
- name: Update version number in source files
38-
env:
39-
VERSION_NUMBER: ${{ github.event.inputs.version_number }}
40-
REPO_NAME: ${{ github.event.repository.name }}
41-
source_folder_list: "source test"
42-
run: |
43-
echo "${{ env.source_folder_list }}" | \
44-
xargs -n 1 sh -c \
45-
'find $1 -type f \( -name "*.c" -o -name "*.h" \) \
46-
-exec sed -i -b -E "0,/^ \* FreeRTOS\+TCP/s/^ \* FreeRTOS\+TCP.*/ \* FreeRTOS\+TCP $VERSION_NUMBER/g" {} +'
47-
git add .
48-
git commit -m '[AUTO][RELEASE]: Update version number in source files'
49-
git push -u origin "$VERSION_NUMBER"
50-
- name: Generate SBOM
51-
uses: FreeRTOS/CI-CD-Github-Actions/sbom-generator@main
52-
with:
53-
repo_path: ./
54-
source_path: ./source
55-
- name: commit SBOM file
56-
env:
57-
VERSION_NUMBER: ${{ github.event.inputs.version_number }}
58-
run: |
59-
git add .
60-
git commit -m 'Update SBOM'
61-
git push -u origin "$VERSION_NUMBER"
62-
- name: Tag Commit and Push to remote
63-
env:
64-
VERSION_NUMBER: ${{ github.event.inputs.version_number }}
65-
run: |
66-
git tag "$VERSION_NUMBER" -a -m "FreeRTOS-Plus-TCP Library $VERSION_NUMBER"
67-
git push origin --tags
68-
- name: Verify tag on remote
69-
env:
70-
VERSION_NUMBER: ${{ github.event.inputs.version_number }}
71-
COMMIT_ID: ${{ github.event.inputs.commit_id }}
72-
run: |
73-
git tag -d "$VERSION_NUMBER"
74-
git remote update
75-
git checkout tags/"$VERSION_NUMBER"
76-
git diff "$COMMIT_ID" tags/"$VERSION_NUMBER"
77-
create-zip:
78-
needs: tag-commit
79-
name: Create ZIP and verify package for release asset.
80-
runs-on: ubuntu-latest
81-
steps:
82-
- name: Install ZIP tools
83-
run: sudo apt-get install zip unzip
84-
- name: Checkout code
85-
uses: actions/checkout@v4
86-
with:
87-
ref: ${{ github.event.inputs.version_number }}
88-
path: FreeRTOS-Plus-TCP
89-
submodules: recursive
90-
- name: Checkout disabled submodules
91-
run: |
92-
cd FreeRTOS-Plus-TCP
93-
git submodule update --init --checkout --recursive
94-
- name: Create ZIP
95-
env:
96-
VERSION_NUMBER: ${{ github.event.inputs.version_number }}
97-
run: |
98-
zip -r FreeRTOS-Plus-TCP-"$VERSION_NUMBER".zip FreeRTOS-Plus-TCP -x "*.git*"
99-
ls ./
100-
- name: Validate created ZIP
101-
env:
102-
VERSION_NUMBER: ${{ github.event.inputs.version_number }}
103-
run: |
104-
mkdir zip-check
105-
mv FreeRTOS-Plus-TCP-"$VERSION_NUMBER".zip zip-check
106-
cd zip-check
107-
unzip FreeRTOS-Plus-TCP-"$VERSION_NUMBER".zip -d FreeRTOS-Plus-TCP-"$VERSION_NUMBER"
108-
ls FreeRTOS-Plus-TCP-"$VERSION_NUMBER"
109-
diff -r -x "*.git*" FreeRTOS-Plus-TCP-"$VERSION_NUMBER"/FreeRTOS-Plus-TCP/ ../FreeRTOS-Plus-TCP/
110-
cd ../
111-
- name: Build
112-
env:
113-
VERSION_NUMBER: ${{ github.event.inputs.version_number }}
114-
run: |
115-
cd zip-check/FreeRTOS-Plus-TCP-"$VERSION_NUMBER"/FreeRTOS-Plus-TCP
116-
sudo apt-get install -y lcov
117-
sudo apt-get install unifdef
118-
cmake -S test/unit-test -B test/unit-test/build/
119-
make -C test/unit-test/build/ all
120-
- name: Test
121-
env:
122-
VERSION_NUMBER: ${{ github.event.inputs.version_number }}
123-
run: |
124-
cd zip-check/FreeRTOS-Plus-TCP-"$VERSION_NUMBER"/FreeRTOS-Plus-TCP
125-
pushd test/unit-test/build/
126-
ctest -E system --output-on-failure
127-
popd
128-
make -C test/unit-test/build/ coverage
129-
lcov --list --rc lcov_branch_coverage=1 test/unit-test/build/coverage.info
130-
cd ..
131-
- name: Create artifact of ZIP
132-
uses: actions/upload-artifact@v4
133-
with:
134-
name: FreeRTOS-Plus-TCP-${{ github.event.inputs.version_number }}.zip
135-
path: zip-check/FreeRTOS-Plus-TCP-${{ github.event.inputs.version_number }}.zip
136-
deploy-doxygen:
137-
needs: tag-commit
138-
name: Deploy doxygen documentation
139-
runs-on: ubuntu-latest
140-
steps:
141-
- name: Doxygen generation
142-
uses: FreeRTOS/CI-CD-Github-Actions/doxygen-generation@main
143-
with:
144-
ref: ${{ github.event.inputs.version_number }}
145-
add_release: "true"
146-
create-release:
147-
permissions:
148-
id-token: write
149-
needs:
150-
- create-zip
151-
- deploy-doxygen
152-
name: Create Release and Upload Release Asset
153-
runs-on: ubuntu-latest
154-
steps:
155-
- name: Create Release
156-
id: create_release
157-
uses: actions/create-release@v1
158-
env:
159-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
160-
with:
161-
tag_name: ${{ github.event.inputs.version_number }}
162-
release_name: ${{ github.event.inputs.version_number }}
163-
body: Release ${{ github.event.inputs.version_number }} of the FreeRTOS-Plus-TCP Library.
164-
draft: false
165-
prerelease: false
166-
- name: Download ZIP artifact
167-
uses: actions/download-artifact@v4
168-
with:
169-
name: FreeRTOS-Plus-TCP-${{ github.event.inputs.version_number }}.zip
170-
- name: Upload Release Asset
171-
id: upload-release-asset
172-
uses: actions/upload-release-asset@v1
173-
env:
174-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
175-
with:
176-
upload_url: ${{ steps.create_release.outputs.upload_url }}
177-
asset_path: ./FreeRTOS-Plus-TCP-${{ github.event.inputs.version_number }}.zip
178-
asset_name: FreeRTOS-Plus-TCP-${{ github.event.inputs.version_number }}.zip
179-
asset_content_type: application/zip
180-
- name: Backup Release Asset
181-
uses: FreeRTOS/CI-CD-Github-Actions/artifact-backup@main
182-
with:
183-
artifact_path: ./FreeRTOS-Plus-TCP-${{ github.event.inputs.version_number }}.zip
184-
release_tag: ${{ github.event.inputs.version_number }}
185-
cleanup:
186-
needs:
187-
- create-release
188-
name: Cleanup
19+
release:
20+
name: Create Release
18921
runs-on: ubuntu-latest
19022
steps:
191-
- name: Checkout code
192-
uses: actions/checkout@v4
193-
- name: Delete branch created for Tag by SBOM generator
194-
env:
195-
VERSION_NUMBER: ${{ github.event.inputs.version_number }}
196-
run: |
197-
# Delete the branch created for Tag by SBOM generator
198-
git push -u origin --delete refs/heads/"$VERSION_NUMBER"
23+
- name: Release
24+
uses: FreeRTOS/CI-CD-Github-Actions/release@main
25+
with:
26+
version_number: ${{ github.event.inputs.version_number }}
27+
branch: ${{ github.event.inputs.branch }}
28+
github_token: ${{ secrets.GITHUB_TOKEN }}
29+
repo_build_command: rm -rf ../build && cmake -S. -B ../build -DSTANDALONE_TEST_BUILD_UNIX=1 && make -C ../build all
30+
run_test_command: 'sudo apt-get install -y lcov unifdef ninja-build && rm -rf ../build && cmake --fresh -G Ninja -S test/unit-test -B ../build/ -DBUILD_CLONE_SUBMODULES=1 -DSANITIZE=address,undefined && ninja -C ../build && ctest --test-dir ../build/ -E system --output-on-failure'

CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,14 @@ add_subdirectory(source)
173173
add_subdirectory(tools)
174174
add_subdirectory(test)
175175

176+
if(STANDALONE_TEST_BUILD_UNIX)
177+
add_library(freertos_config INTERFACE)
178+
target_include_directories(freertos_config INTERFACE
179+
${CMAKE_CURRENT_SOURCE_DIR}/test/build-combination/Common
180+
)
181+
set(FREERTOS_PORT GCC_POSIX CACHE STRING "")
182+
endif()
183+
176184
if(PROJECT_IS_TOP_LEVEL)
177185
FetchContent_MakeAvailable(freertos_kernel cmock)
178186
endif()

source/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@ target_include_directories( freertos_plus_tcp
9292
include
9393
)
9494

95+
if(STANDALONE_TEST_BUILD_UNIX)
96+
target_include_directories(freertos_plus_tcp
97+
PUBLIC
98+
${CMAKE_CURRENT_SOURCE_DIR}/../test/build-combination/DefaultConf )
99+
endif()
100+
95101
target_link_libraries( freertos_plus_tcp
96102
PUBLIC
97103
freertos_config

test/unit-test/cmock_build.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ macro( clone_cmock )
33
find_package( Git REQUIRED )
44
message( "Cloning submodule CMock." )
55
execute_process( COMMAND rm -rf ${CMOCK_DIR}
6-
COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive ${CMOCK_DIR}
6+
COMMAND ${GIT_EXECUTABLE} submodule update --init --checkout --force --recursive ${CMOCK_DIR}
77
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
88
RESULT_VARIABLE CMOCK_CLONE_RESULT )
99

0 commit comments

Comments
 (0)