Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

github.workflow: Adds continuous and release GitHub workflows. #3

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/continuous.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Build and Test

on:
push:
branches: [ master, release-2.9, team/platform/dev ]
pull_request:
branches: [ master, release-2.9, team/platform/dev ]

env:
FEED: https://github.com/victorpaleologue/libqi/releases/download/v1.8.8-actions/feed.xml

jobs:
build:
# The CMake configure and build commands are platform agnostic and should work equally
# well on Windows or Mac. You can convert this to a matrix build if you need
# cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
runs-on: ubuntu-20.04

steps:

- name: Install Build Tools
run: pip install qibuild

- name: Install Dependencies
# TODO move these dependencies in the toolchain
run: sudo apt install libgtest-dev libgmock-dev

- uses: actions/checkout@v2

- name: Prepare QiBuild Toolchain
run: qitoolchain create qisdk $FEED

- name: Prepare QiBuild Config
run: |
qibuild init
qibuild add-config qisdk -t qisdk

- name: Configure
run: qibuild configure -c qisdk --debug -DQI_WITH_TESTS=ON -DCMAKE_CXX_FLAGS=-pthread

- name: Build
run: qibuild make -c qisdk

- name: Test
run: qitest run -c qisdk
27 changes: 27 additions & 0 deletions .github/workflows/make_feed.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash
# Retrieves the latest release output to generate a QiToolchain XML feed.
set -e
RELEASE_URL="${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases/${CURRENT_RELEASE_TAG}"
echo "Getting packages from current release at $RELEASE_URL"
ASSETS_URL=$(curl --silent $RELEASE_URL |
jq -r '.assets_url')
PACKAGES_URLS=$(curl --silent $ASSETS_URL |
jq '.[] | .browser_download_url' |
grep .zip | xargs -L 1 echo) # echo removes the extra quotes

echo "Making a toolchain feed."
echo "<toolchain>" > feed.xml
echo "Adding sub-toolchain from ${FEED}"
echo " <feed url=\"${FEED}\" />" >> feed.xml
echo "Adding links for the following packages:" ${PACKAGES_URLS}
for URL in $PACKAGES_URLS; do
ZIP=package.zip
wget -q $URL -O $ZIP;
NAME=$(unzip -p $ZIP package.xml | xmllint --xpath "string(/package/@name)" -)
VERSION=$(unzip -p $ZIP package.xml | xmllint --xpath "string(/package/@version)" -)
echo " <package name=\"${NAME}\" version=\"${VERSION}\" url=\"${URL}\" />" >> feed.xml
rm $ZIP
done
echo "</toolchain>" >> feed.xml

realpath feed.xml
68 changes: 68 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Release with Toolchain

on:
push:
tags: "v*"

env:
FEED: https://github.com/victorpaleologue/libqi/releases/download/v1.8.8-actions/feed.xml

jobs:
gh_tagged_release:
# The CMake configure and build commands are platform agnostic and should work equally
# well on Windows or Mac. You can convert this to a matrix build if you need
# cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
runs-on: ubuntu-20.04

steps:

- name: Install Utilities
run: sudo apt install apt-utils ca-certificates locales curl wget jq libxml2-utils xmlstarlet

- name: Install Build Tools
run: pip install qibuild

- name: Install Dependencies
# TODO move these dependencies in the toolchain
run: sudo apt install libgtest-dev libgmock-dev

- uses: actions/checkout@v2

- name: Prepare QiBuild Toolchain
run: qitoolchain create qisdk $FEED

- name: Prepare QiBuild Config
run: |
qibuild init
qibuild add-config qisdk -t qisdk

- name: Set Version
run: xmlstarlet ed --inplace -i '/project/qibuild' -t attr -n version -v `git describe --tags` qiproject.xml

- name: Build QiToolchain Package # Outputs the package as a .zip in ./package/
run: qibuild package -c qisdk --release -DQI_WITH_TESTS=OFF -DCMAKE_CXX_FLAGS=-pthread

- name: Release Package
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
files: |
package/*.zip
id: "release"

- name: Make Feed # Outputs feed.xml
run: .github/workflows/make_feed.sh
env:
CURRENT_RELEASE_TAG: ${{ steps.release.outputs.automatic_releases_tag }}

- name: Release Feed
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.release.outputs.upload_url }}
asset_path: feed.xml
asset_name: feed.xml
asset_content_type: application/xml
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ qi_use_lib(qilang qi)
qi_stage_lib(qilang)


qi_create_bin(qicc src/qic_main.cpp DEPENDS qi qilang)
qi_create_bin(qicc src/qic_main.cpp DEPENDS qi qilang boost_chrono)
qi_stage_bin(qicc)

qi_stage_cmake(qilang-tools-config.cmake)
Expand Down
2 changes: 1 addition & 1 deletion qilang-tools-config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ function(qi_gen_idl OUT lang pkg dir)
SRC "${abs_idl_path}"
COMMENT "Generating remote proxy implementation ${generated_path}"
DEPENDS "${QICC_EXECUTABLE}" "${staged_idl_path}" ${mirror_idl_file_target}
COMMAND "${QICC_EXECUTABLE}" -c cpp_remote "${staged_idl_path}" -o "${generated_path}" -t ${QI_SDK_DIR})
COMMAND readelf -d "${CMAKE_CURRENT_SOURCE_DIR}/../build-qisdk/sdk/bin/qicc" | head -20 && readelf -d "/home/runner/.local/share/qi/toolchains/qisdk/libqi/lib/libqi.so" | head -20 && "${QICC_EXECUTABLE}" -c cpp_remote "${staged_idl_path}" -o "${generated_path}" -t ${QI_SDK_DIR})
list(APPEND _out "${generated_path}")
list(APPEND _${OUT}_REMOTE "${generated_path}")
message(STATUS "Will generate C++ remote proxy implementation: ${generated_path}")
Expand Down
9 changes: 3 additions & 6 deletions src/format_doc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

#include <iostream>
#include <ka/scoped.hpp>
#include <qi/log.hpp>
#include <qilang/node.hpp>
#include <qilang/formatter.hpp>
Expand All @@ -14,8 +15,6 @@
#include <qi/os.hpp>
#include "formatter_p.hpp"
#include <boost/algorithm/string/replace.hpp>
#include <boost/lambda/lambda.hpp>
#include <boost/scope_exit.hpp>
#include <stack>
#include "cpptype.hpp"

Expand Down Expand Up @@ -94,7 +93,7 @@ class QiLangGenDoc: public NodeFormatter<>
}

std::stack<bool> first;
boost::scoped_ptr<Doc> curDoc;
std::unique_ptr<Doc> curDoc;

void putComma() {
if (first.top())
Expand Down Expand Up @@ -169,9 +168,7 @@ class QiLangGenDoc: public NodeFormatter<>

curDoc.reset(new Doc(doc));
}
BOOST_SCOPE_EXIT(&curDoc) {
curDoc.reset();
} BOOST_SCOPE_EXIT_END
ka::scoped([this] { curDoc.reset(); });

out() << "\"" << node->name << "\" : {";
out() << "\"type\" : \"method\", ";
Expand Down
46 changes: 22 additions & 24 deletions src/token.l
Original file line number Diff line number Diff line change
Expand Up @@ -84,36 +84,34 @@

#define STEP() LOC.step()

#define YY_INPUT(buf, result, max_size) qilang_readsome(yyextra, buf, &result, max_size)
// See https://www.cs.princeton.edu/~appel/modern/c/software/flex/flex.html#SEC10
#define YY_INPUT(buf, result, max_size) \
{ \
auto p = yyextra; \
if (p->file->in().eof() || p->file->in().fail()) { \
result = 0; \
} else { \
p->file->in().readsome(buf, max_size); \
if (!p->file->in().gcount() && !p->file->in().eof()) \
{ \
p->file->in().peek(); \
p->file->in().readsome(buf, max_size); \
} \
if (p->file->in().bad()) \
{ \
result = -1; \
} else { \
result = p->file->in().gcount(); \
} \
} \
}

#ifdef _WIN32
static bool isatty(int fp) {
return false;
}
#endif
#ifdef _WIN32
static void qilang_readsome(qilang::Parser* p, char* buf, int *result, size_t max_size)
#else
static void qilang_readsome(qilang::Parser* p, char* buf, yy_size_t *result, size_t max_size)
#endif
{
if (p->file->in().eof() || p->file->in().fail()) {
*result = 0;
return;
}
p->file->in().readsome(buf, max_size);
if (!p->file->in().gcount() && !p->file->in().eof())
{
p->file->in().peek();
p->file->in().readsome(buf, max_size);
}
if (p->file->in().bad())
{
*result = -1;
return;
}
*result = p->file->in().gcount();
}


#define yyterminate() \
return yy::parser::make_END_OF_FILE(LOC)
Expand Down