Skip to content

Commit

Permalink
merge to nam20485 (#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
nam20485 authored Jan 31, 2024
2 parents e05fef7 + e8a5d87 commit 65adca9
Show file tree
Hide file tree
Showing 71 changed files with 1,739 additions and 526 deletions.
112 changes: 1 addition & 111 deletions .github/workflows/cmake-multi-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: CMake Build Multi-Platform

on:
push:
branches: [ "development", "main", "release", "nam20485" ]
branches: [ "nam20485" ]
pull_request:
branches: [ "development", "main", "release", "nam20485" ]

Expand Down Expand Up @@ -212,113 +212,3 @@ jobs:
name: ${{ matrix.os }}-artifacts
path: ${{ env.ARTIFACTS_DIR }}/artifacts-${{matrix.os}}.zip
retention-days: 1

#
# Create Release job
#

release:
# only on pushes to the release branch
name: Create Release
needs: build
if: ${{ (github.ref_name == 'release') && github.event_name == 'push' }}
runs-on: ubuntu-22.04
permissions:
contents: write

steps:

- name: Checkout Repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

# download the artifacts
- name: "Download artifacts"
uses: "actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935" # v4.1.1
with:
path: ${{ github.workspace }}/artifacts

- name: Rename Artifacts
run: |
mv ${{ github.workspace }}/artifacts/ubuntu-22.04-artifacts/artifacts-ubuntu-22.04.zip ${{ github.workspace }}/artifacts/OdbDesign-Linux-x64.zip
mv ${{ github.workspace }}/artifacts/windows-2022-artifacts/artifacts-windows-2022.zip ${{ github.workspace }}/artifacts/OdbDesign-Windows-x64.zip
mv ${{ github.workspace }}/artifacts/macos-12-artifacts/artifacts-macos-12.zip ${{ github.workspace }}/artifacts/OdbDesign-MacOS-x64.zip
- name: Generate SHA256 Sums
run: |
# sha256
cd ${{ github.workspace }}/artifacts
sha256sum OdbDesign-Linux-x64.zip > OdbDesign-Linux-x64.zip.sha256sum
sha256sum OdbDesign-Windows-x64.zip > OdbDesign-Windows-x64.zip.sha256sum
sha256sum OdbDesign-MacOS-x64.zip > OdbDesign-MacOS-x64.zip.sha256sum
- name: Import GPG Key
uses: crazy-max/ghaction-import-gpg@01dd5d3ca463c7f10f7f4f7b4f177225ac661ee4 # v6.1.0
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}

- name: Sign Binaries
run: |
cd ${{ github.workspace }}/artifacts
gpg --batch --yes --detach-sign --armor OdbDesign-Linux-x64.zip
gpg --batch --yes --detach-sign --armor OdbDesign-Windows-x64.zip
gpg --batch --yes --detach-sign --armor OdbDesign-MacOS-x64.zip
- name: Create Release Variables
run: |
export RELEASE_VERSION="${{vars.RELEASE_VERSION_PREFIX}}.${{github.run_number}}"
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV
export RELEASE_TAG="v${RELEASE_VERSION}"
echo "RELEASE_TAG=$RELEASE_TAG" >> $GITHUB_ENV
export RELEASE_NAME="OdbDesign ${RELEASE_TAG}"
echo "RELEASE_NAME=$RELEASE_NAME" >> $GITHUB_ENV
# create a release
- name: "Create GitHub Release"
uses: "actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea" # v7.0.1
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
script: |
try {
const createResponse = await github.rest.repos.createRelease({
generate_release_notes: true,
name: process.env.RELEASE_NAME,
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: process.env.RELEASE_TAG,
body: require('fs').readFileSync('${{ github.workspace }}/release/release-body.md', 'utf8'),
target_commitish: '${{ github.ref_name }}'
});
const files =
[
{ name: 'OdbDesign-Linux-x64.zip', contentType: 'application/zip' },
{ name: 'OdbDesign-Linux-x64.zip.sha256sum', contentType: 'text/plain' },
{ name: 'OdbDesign-Linux-x64.zip.asc', contentType: 'text/plain' },
{ name: 'OdbDesign-Windows-x64.zip', contentType: 'application/zip' },
{ name: 'OdbDesign-Windows-x64.zip.sha256sum', contentType: 'text/plain' },
{ name: 'OdbDesign-Windows-x64.zip.asc', contentType: 'text/plain' },
{ name: 'OdbDesign-MacOS-x64.zip', contentType: 'application/zip' },
{ name: 'OdbDesign-MacOS-x64.zip.sha256sum', contentType: 'text/plain' },
{ name: 'OdbDesign-MacOS-x64.zip.asc', contentType: 'text/plain' }
];
const artifactsPath = '${{ github.workspace }}/artifacts';
for (const file of files) {
const filePath = artifactsPath +'/' + file.name;
const uploadResponse = await github.rest.repos.uploadReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: createResponse.data.id,
name: file.name,
data: require('fs').readFileSync(filePath),
headers: {
'content-type': file.contentType,
'content-length': require('fs').statSync(filePath).size
}
});
}
} catch (error) {
core.setFailed(error.message);
}
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ name: "CodeQL Security Scan"

on:
push:
branches: [ "development", "main", "release", "nam20485" ]
branches: [ "nam20485" ]
pull_request:
branches: [ "development", "main", "release", "nam20485" ]

Expand Down
122 changes: 122 additions & 0 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
# run CMake build on Windows and Linux
name: Create Release

on:
push:
branches: [ "release" ]

permissions:
contents: read

env:
ARTIFACTS_DIR: ${{ github.workspace }}/artifacts
ARTIFACTS_DIR_WIN: ${{ github.workspace }}\artifacts

jobs:

release:

# only on pushes to the release branch
name: Create Release
#needs: build
if: ${{ (github.ref_name == 'release') && github.event_name == 'push' }}
runs-on: ubuntu-22.04
permissions:
contents: write

steps:

- name: Checkout Repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

# download the artifacts
- name: "Download artifacts"
uses: "actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935" # v4.1.1
with:
path: ${{ github.workspace }}/artifacts

- name: Rename Artifacts
run: |
mv ${{ github.workspace }}/artifacts/ubuntu-22.04-artifacts/artifacts-ubuntu-22.04.zip ${{ github.workspace }}/artifacts/OdbDesign-Linux-x64.zip
mv ${{ github.workspace }}/artifacts/windows-2022-artifacts/artifacts-windows-2022.zip ${{ github.workspace }}/artifacts/OdbDesign-Windows-x64.zip
mv ${{ github.workspace }}/artifacts/macos-12-artifacts/artifacts-macos-12.zip ${{ github.workspace }}/artifacts/OdbDesign-MacOS-x64.zip
- name: Generate SHA256 Sums
run: |
# sha256
cd ${{ github.workspace }}/artifacts
sha256sum OdbDesign-Linux-x64.zip > OdbDesign-Linux-x64.zip.sha256sum
sha256sum OdbDesign-Windows-x64.zip > OdbDesign-Windows-x64.zip.sha256sum
sha256sum OdbDesign-MacOS-x64.zip > OdbDesign-MacOS-x64.zip.sha256sum
- name: Import GPG Key
uses: crazy-max/ghaction-import-gpg@01dd5d3ca463c7f10f7f4f7b4f177225ac661ee4 # v6.1.0
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}

- name: Sign Binaries
run: |
cd ${{ github.workspace }}/artifacts
gpg --batch --yes --detach-sign --armor OdbDesign-Linux-x64.zip
gpg --batch --yes --detach-sign --armor OdbDesign-Windows-x64.zip
gpg --batch --yes --detach-sign --armor OdbDesign-MacOS-x64.zip
- name: Create Release Variables
run: |
export RELEASE_VERSION="${{vars.RELEASE_VERSION_PREFIX}}.${{github.run_number}}"
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV
export RELEASE_TAG="v${RELEASE_VERSION}"
echo "RELEASE_TAG=$RELEASE_TAG" >> $GITHUB_ENV
export RELEASE_NAME="OdbDesign ${RELEASE_TAG}"
echo "RELEASE_NAME=$RELEASE_NAME" >> $GITHUB_ENV
# create a release
- name: "Create GitHub Release"
uses: "actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea" # v7.0.1
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
script: |
try {
const createResponse = await github.rest.repos.createRelease({
generate_release_notes: true,
name: process.env.RELEASE_NAME,
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: process.env.RELEASE_TAG,
body: require('fs').readFileSync('${{ github.workspace }}/release/release-body.md', 'utf8'),
target_commitish: '${{ github.ref_name }}'
});
const files =
[
{ name: 'OdbDesign-Linux-x64.zip', contentType: 'application/zip' },
{ name: 'OdbDesign-Linux-x64.zip.sha256sum', contentType: 'text/plain' },
{ name: 'OdbDesign-Linux-x64.zip.asc', contentType: 'text/plain' },
{ name: 'OdbDesign-Windows-x64.zip', contentType: 'application/zip' },
{ name: 'OdbDesign-Windows-x64.zip.sha256sum', contentType: 'text/plain' },
{ name: 'OdbDesign-Windows-x64.zip.asc', contentType: 'text/plain' },
{ name: 'OdbDesign-MacOS-x64.zip', contentType: 'application/zip' },
{ name: 'OdbDesign-MacOS-x64.zip.sha256sum', contentType: 'text/plain' },
{ name: 'OdbDesign-MacOS-x64.zip.asc', contentType: 'text/plain' }
];
const artifactsPath = '${{ github.workspace }}/artifacts';
for (const file of files) {
const filePath = artifactsPath +'/' + file.name;
const uploadResponse = await github.rest.repos.uploadReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: createResponse.data.id,
name: file.name,
data: require('fs').readFileSync(filePath),
headers: {
'content-type': file.contentType,
'content-length': require('fs').statSync(filePath).size
}
});
}
} catch (error) {
core.setFailed(error.message);
}
4 changes: 2 additions & 2 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ name: Docker Publish
on:
push:
branches: [ "development", "main", "release", "nam20485" ]
pull_request:
branches: [ "development", "main", "release", "nam20485" ]
#pull_request:
# branches: [ "development", "main", "release", "nam20485" ]

env:
# Use docker.io for Docker Hub if empty
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker-scout-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name: Docker Scout Scan

on:
push:
branches: [ "development", "main", "release", "nam20485" ]
branches: [ "nam20485" ]
pull_request:
branches: [ "development", "main", "release", "nam20485" ]

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ on:
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained
schedule:
- cron: '26 13 * * 3'
push:
branches: [ "development" ]
#push:
# branches: [ "development" ]
pull_request:
branches: [ "development" ]

Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,5 @@ if (DOXYGEN_FOUND)
COMMENT "Generating API documentation with Doxygen"
VERBATIM )
else (DOXYGEN_FOUND)
message("Doxygen need to be installed to generate the doxygen documentation")
message("Doxygen needs to be installed to generate the doxygen documentation")
endif (DOXYGEN_FOUND)
14 changes: 12 additions & 2 deletions OdbDesignLib/App/BasicRequestAuthentication.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
#include "BasicRequestAuthentication.h"
#include <string>
#include "macros.h"

using namespace Utils;

namespace Odb::Lib::App
{
crow::response BasicRequestAuthentication::AuthenticateRequest(const crow::request& req)
{
// if running debug build AND in Local environment, bypass authentication
if (IsDebug() && IsLocal())
{
// 200 Authorized!
return crow::response(200, "Authorized");
}

const auto& authHeader = req.get_header_value("Authorization");
if (authHeader.empty()) return crow::response(401, "Unauthorized");

Expand All @@ -29,10 +39,10 @@ namespace Odb::Lib::App
{
// 500 - Internal Server Error
auto validUsername = std::getenv(USERNAME_ENV_NAME);

Check warning on line 41 in OdbDesignLib/App/BasicRequestAuthentication.cpp

View workflow job for this annotation

GitHub Actions / CMake-Multi-Platform-Build (windows-2022, x64-release)

'getenv': This function or variable may be unsafe. Consider using _dupenv_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
if (validUsername == nullptr) return crow::response(500, "Server failed retrieving credentials");
if (validUsername == nullptr) return crow::response(500, "Failed retrieving credentials");

auto validPassword = std::getenv(PASSWORD_ENV_NAME);

Check warning on line 44 in OdbDesignLib/App/BasicRequestAuthentication.cpp

View workflow job for this annotation

GitHub Actions / CMake-Multi-Platform-Build (windows-2022, x64-release)

'getenv': This function or variable may be unsafe. Consider using _dupenv_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
if (validPassword == nullptr) return crow::response(500, "Server failed retrieving credentials");
if (validPassword == nullptr) return crow::response(500, "Failed retrieving credentials");

// 403 - Forbidden
if (username != validUsername ||
Expand Down
2 changes: 1 addition & 1 deletion OdbDesignLib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ target_link_libraries(OdbDesign PRIVATE Crow::Crow)
find_package(Protobuf CONFIG REQUIRED)
#protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS protoc/edadatafile.proto)
#target_link_libraries(OdbDesign PUBLIC protobuf::libprotoc protobuf::libprotobuf protobuf::libprotobuf-lite)
target_link_libraries(OdbDesign PRIVATE protobuf::libprotobuf)
target_link_libraries(OdbDesign PUBLIC protobuf::libprotobuf)
# mark the generated Protofbuf C++ files as generated
#set_source_files_properties(${PROTO_SRC} ${PROTO_HDRS} PROPERTIES GENERATED TRUE)
# add the generated Protobuf C++ files to the target
Expand Down
3 changes: 2 additions & 1 deletion OdbDesignLib/FileModel/Design/ComponentsFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,8 @@ namespace Odb::Lib::FileModel::Design

if (!(lineStream >> description))
{
throw_parse_error(m_path, line, token, lineNumber);
// allow blank/no description value
//throw_parse_error(m_path, line, token, lineNumber);
}

pCurrentBomDescriptionRecord->descriptions.push_back(description);
Expand Down
4 changes: 4 additions & 0 deletions OdbDesignLib/FileModel/Design/FileArchive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ namespace Odb::Lib::FileModel::Design
std::unique_ptr<Odb::Lib::Protobuf::FileArchive> FileArchive::to_protobuf() const
{
std::unique_ptr<Odb::Lib::Protobuf::FileArchive> pFileArchiveMessage(new Odb::Lib::Protobuf::FileArchive);
pFileArchiveMessage->set_productname(m_productName);
pFileArchiveMessage->set_filename(m_filename);
pFileArchiveMessage->mutable_matrixfile()->CopyFrom(*m_matrixFile.to_protobuf());
pFileArchiveMessage->mutable_miscinfofile()->CopyFrom(*m_miscInfoFile.to_protobuf());
pFileArchiveMessage->mutable_standardfontsfile()->CopyFrom(*m_standardFontsFile.to_protobuf());
Expand All @@ -186,6 +188,8 @@ namespace Odb::Lib::FileModel::Design

void FileArchive::from_protobuf(const Odb::Lib::Protobuf::FileArchive& message)
{
m_productName = message.productname();
m_filename = message.filename();
m_matrixFile.from_protobuf(message.matrixfile());
m_miscInfoFile.from_protobuf(message.miscinfofile());
m_standardFontsFile.from_protobuf(message.standardfontsfile());
Expand Down
8 changes: 4 additions & 4 deletions OdbDesignLib/FileModel/Design/FileArchive.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ namespace Odb::Lib::FileModel::Design

bool ParseFileModel();

// Inherited via IProtoBuffable
std::unique_ptr<Odb::Lib::Protobuf::FileArchive> to_protobuf() const override;
void from_protobuf(const Odb::Lib::Protobuf::FileArchive& message) override;

typedef std::vector<std::shared_ptr<FileArchive>> Vector;
typedef std::map<std::string, std::shared_ptr<FileArchive>> StringMap;

Expand Down Expand Up @@ -73,10 +77,6 @@ namespace Odb::Lib::FileModel::Design
static std::string findRootDir(const std::filesystem::path& extractedPath);
static bool pathContainsTopLevelDesignDirs(const std::filesystem::path& path);

// Inherited via IProtoBuffable
std::unique_ptr<Odb::Lib::Protobuf::FileArchive> to_protobuf() const override;
void from_protobuf(const Odb::Lib::Protobuf::FileArchive& message) override;

static inline constexpr const char* TOPLEVEL_DESIGN_DIR_NAMES[] =
{
"fonts",
Expand Down
3 changes: 1 addition & 2 deletions OdbDesignLib/IProtoBuffable.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ namespace Odb::Lib

protected:
// abstract class
IProtoBuffable()
{}
IProtoBuffable() = default;

// TMessage MUST derive from Message (must use this until template type contraints support is added)
static_assert(std::is_base_of<google::protobuf::Message, TPbMessage>::value, "template parameter type TPbMessage must derive from Protobuf Message class");
Expand Down
Loading

0 comments on commit 65adca9

Please sign in to comment.