From 28ed1548ee37f93913c92b79c84ffb89a296d946 Mon Sep 17 00:00:00 2001 From: Jaromil Date: Wed, 28 Dec 2022 07:36:31 +0100 Subject: [PATCH] feat: test suite and ci improvements linux build is dismissed (using distro packages or source recommended) and release builds target win64 built using msvc also implemented skip labels: - skip-test - skip-lint - skip-release test will list info about plugins found in any directory in a json file also includes various ci fixes --- .github/workflows/main.yml | 131 +++++++++++++++++++++---------------- test/Makefile | 15 +++-- test/frei0r-info.c | 73 ++++++++++++++++++--- 3 files changed, 151 insertions(+), 68 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ddfbaea..4a681c8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -30,6 +30,7 @@ jobs: c-lint: name: 🚨 C lint runs-on: ubuntu-latest + if: "!contains(github.event.pull_request.labels.*.name, 'skip-lint')" steps: - uses: actions/checkout@v3 - uses: reviewdog/action-cpplint@master @@ -58,16 +59,44 @@ jobs: ,-whitespace/semicolon\ ,-build/include_subdir\ ,-build/include_order\ - " # Optional - # - name: Fail fast?! - # if: steps.linter.outputs.checks-failed > 0 - # run: | - # echo "😤 Some files failed the C linting checks!" + " + test-suite: + name: 🔬 test + needs: [c-lint] + if: "!contains(github.event.pull_request.labels.*.name, 'skip-test')" + strategy: + matrix: + compiler: [clang-14] + fail-fast: false + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: install dependencies + run: | + sudo apt-get update -qy + sudo apt-get install --no-install-recommends -y ${{ matrix.compiler }} cmake ninja-build libfreetype-dev libopencv-dev libcairo2-dev libgavl-dev + - name: ${{ matrix.compiler }} initialize cmake build + run: | + mkdir -p build && cd build + cmake -G "Ninja" ../ + - name: ${{ matrix.compiler }} run ninja build + run: | + cd build && ninja + - name: ${{ matrix.compiler }} analyze plugins + run: | + cd test && make + - name: ${{ matrix.compiler }} upload plugin analysis + uses: actions/upload-artifact@v3 + with: + name: release-plugin-analysis + path: test/*.json semantic-release: name: 🤖 Semantic release runs-on: ubuntu-latest + needs: [test-suite] + if: "!contains(github.event.pull_request.labels.*.name, 'skip-release')" # if: ${{ github.ref_name == 'master' && github.event_name == 'push' }} outputs: release: ${{ steps.tag_release.outputs.release }} @@ -95,51 +124,42 @@ jobs: awk '/Published release/ { printf("version=v%s\n",$8) }' semantic-release.log >> $GITHUB_OUTPUT fi - cmake-build: - name: 🏗️ cmake build linux amd64 - needs: [c-lint, semantic-release] - if: "!contains(github.event.pull_request.labels.*.name, 'SKIP_MESON')" - strategy: - matrix: - compiler: [clang-14] - fail-fast: false - runs-on: ubuntu-latest + msvc-build: + name: 💻 msvc build win64 + runs-on: windows-latest + needs: [semantic-release, test-suite, c-lint] + if: ${{ needs.semantic-release.outputs.release == 'True' }} steps: - uses: actions/checkout@v3 - - name: install compiler and dependencies - run: | - sudo apt-get update -qy - sudo apt-get install --no-install-recommends -y ${{ matrix.compiler }} cmake ninja-build -# libfreetype-dev libopencv-dev libcairo2-dev libgavl-dev - - name: ${{ matrix.compiler }} initialize cmake build - run: | - mkdir -p build && cd build - cmake -G "Ninja" ../ - - name: ${{ matrix.compiler }} make build - run: | - cd build && ninja - - name: Upload artifacts from clang build - uses: actions/upload-artifact@v3 - if: ${{ needs.semantic-release.outputs.release == 'True' }} + - uses: ilammy/msvc-dev-cmd@v1 + - name: choco install deps + uses: crazy-max/ghaction-chocolatey@v2 with: - name: release-filters-linux-amd64 - path: build/src/filter/**/*.so - - name: Upload artifacts from clang build + args: install libopencv-dev + - name: Build using nmake + run: | + mkdir build && cd build + cmake -G "NMake Makefiles" ../ + nmake + - name: Upload win64 filters uses: actions/upload-artifact@v3 - if: ${{ needs.semantic-release.outputs.release == 'True' }} with: - name: release-mixers-linux-amd64 - path: build/src/mixer*/**/*.so - - name: Upload artifacts from clang build + name: release-win64-filters + path: build/src/filter/**/*.dll + - name: Upload win64 mixers uses: actions/upload-artifact@v3 - if: ${{ needs.semantic-release.outputs.release == 'True' }} with: - name: release-generators-linux-amd64 - path: build/src/generator/**/*.so + name: release-win64-mixers + path: build/src/mixer*/**/*.dll + - name: Upload win64 generators + uses: actions/upload-artifact@v3 + with: + name: release-win64-generators + path: build/src/generator/**/*.dll draft-binary-release: name: 📦 Pack release - needs: [cmake-build, semantic-release] + needs: [semantic-release, msvc-build] if: ${{ needs.semantic-release.outputs.release == 'True' }} runs-on: ubuntu-latest steps: @@ -149,35 +169,36 @@ jobs: with: path: | frei0r-bin - - name: show directory structure - run: tree -dL 3 - name: create compressed archives run: | cd frei0r-bin - dst=frei0r-mixers_${{ needs.semantic-release.outputs.version }}_linux-amd64 - mkdir $dst && find release-mixers-linux-amd64 -type f -name '*.so' -exec cp {} $dst \; + dst=frei0r-filters_${{ needs.semantic-release.outputs.version }}_win64 + mkdir $dst && find release-win64-filters -type f -name '*.dll' -exec cp {} $dst \; cp ../README.md ../COPYING ../ChangeLog ../AUTHORS $dst echo "${{ needs.semantic-release.outputs.version }}" > $dst/VERSION - tar cfz $dst.tar.gz $dst - dst=frei0r-filters_${{ needs.semantic-release.outputs.version }}_linux-amd64 - mkdir $dst && find release-filters-linux-amd64 -type f -name '*.so' -exec cp {} $dst \; + zip -r -9 $dst.zip $dst + dst=frei0r-mixers_${{ needs.semantic-release.outputs.version }}_win64 + mkdir $dst && find release-win64-mixers -type f -name '*.dll' -exec cp {} $dst \; cp ../README.md ../COPYING ../ChangeLog ../AUTHORS $dst echo "${{ needs.semantic-release.outputs.version }}" > $dst/VERSION - tar cfz $dst.tar.gz $dst - dst=frei0r-generators_${{ needs.semantic-release.outputs.version }}_linux-amd64 - mkdir $dst && find release-generators-linux-amd64 -type f -name '*.so' -exec cp {} $dst \; + zip -r -9 $dst.zip $dst + dst=frei0r-generators_${{ needs.semantic-release.outputs.version }}_win64 + mkdir $dst && find release-win64-generators -type f -name '*.dll' -exec cp {} $dst \; cp ../README.md ../COPYING ../ChangeLog ../AUTHORS $dst echo "${{ needs.semantic-release.outputs.version }}" > $dst/VERSION - tar cfz $dst.tar.gz $dst - sha256sum *.tar.gz > SHA256SUMS.txt - - name: relase all archives + zip -r -9 $dst.zip $dst + sha256sum *.zip > SHA256SUMS.txt + - name: show directory structure + run: tree -dL 3 + - name: release all archives uses: softprops/action-gh-release@v1 with: files: | - frei0r-bin/*.tar.gz + frei0r-bin/*.zip frei0r-bin/SHA256SUMS.txt + frei0r-bin/release-plugin-analysis/*.json tag_name: ${{ needs.semantic-release.outputs.version }} - draft: false + draft: true prerelease: false fail_on_unmatched_files: true generate_release_notes: true diff --git a/test/Makefile b/test/Makefile index f35e405..70e924c 100644 --- a/test/Makefile +++ b/test/Makefile @@ -1,10 +1,17 @@ INCLUDES ?= -I ../include -all: build scan-filters +PLUGINDIR ?= ../build/src -scan-filters: - @$(if $(wildcard ../build),,>&2 echo "Test needs a ../build" && exit 1) - @find ../build/src -type f -name '*.so' -exec ./frei0r-info {} \; > tmp.json && echo "[" > frei0r-plugin-list.json && head -n -1 tmp.json >> frei0r-plugin-list.json && echo "}\n]" >> frei0r-plugin-list.json && rm tmp.json && >&2 echo "frei0r-plugin-list.json" +all: build scan-plugins + +scan-plugins: + @$(if $(wildcard ${PLUGINDIR}),,>&2 echo "Scan dir not found: ${PLUGINDIR}" && exit 1) + @find ${PLUGINDIR} -type f -name '*.so' -exec ./frei0r-info {} \; > tmp.json + @echo "[" > frei0r-plugin-list.json + @head -n -1 tmp.json >> frei0r-plugin-list.json + @echo "}\n]" >> frei0r-plugin-list.json + @rm tmp.json + $(info frei0r-plugin-list.json) build: @${CC} -o frei0r-info -ggdb frei0r-info.c ${INCLUDES} diff --git a/test/frei0r-info.c b/test/frei0r-info.c index 9ab9b51..de03085 100644 --- a/test/frei0r-info.c +++ b/test/frei0r-info.c @@ -4,34 +4,54 @@ #include #include #include +#include #include +// frei0r function prototypes +typedef int (*f0r_init_f)(void); +typedef void (*f0r_deinit_f)(void); typedef void (*f0r_get_plugin_info_f)(f0r_plugin_info_t *info); -/* typedef void (*f0r_get_param_info_f)(f0r_param_info_t *info, int param_index); */ -/* typedef void (*f0r_get_param_value_f)(f0r_instance_t instance, f0r_param_t param, int param_index); */ - -/* f0r_get_param_info_f get_param_info; */ -/* f0r_get_param_value_f get_param_value; */ +typedef void (*f0r_get_param_info_f)(f0r_param_info_t *info, int param_index); int main(int argc, char **argv) { + + // instance frei0r pointers static void *dl_handle; + static f0r_init_f f0r_init; + static f0r_init_f f0r_deinit; static f0r_plugin_info_t pi; static f0r_get_plugin_info_f f0r_get_plugin_info; + static f0r_get_param_info_f f0r_get_param_info; + static f0r_param_info_t param; + + int c; + if(argc<2) exit(1); + const char *file = basename(argv[1]); + const char *dir = dirname(argv[1]); + char path[256];; + snprintf(path, 255,"%s/%s",dir,file); + // fprintf(stderr,"%s %s\n",argv[0], file); // load shared library - dl_handle = dlopen(argv[1], RTLD_NOW|RTLD_LOCAL); + dl_handle = dlopen(path, RTLD_NOW|RTLD_LOCAL); if(!dl_handle) { fprintf(stderr,"error: %s\n",dlerror()); exit(1); } - // get plugin info + // get plugin function calls + f0r_init = dlsym(dl_handle,"f0r_init"); + f0r_deinit = dlsym(dl_handle,"f0r_deinit"); f0r_get_plugin_info = dlsym(dl_handle,"f0r_get_plugin_info"); + f0r_get_param_info = dlsym(dl_handle,"f0r_get_param_info"); + // always initialize plugin first + f0r_init(); + // get info about plugin f0r_get_plugin_info(&pi); fprintf(stdout, "{\n \"name\":\"%s\",\n \"type\":\"%s\",\n \"author\":\"%s\",\n" - "\"explanation\":\"%s\",\n \"color_model\":\"%s\",\n" - "\"frei0r_version\":\"%d\",\n \"version\":\"%d.%d\",\n \"num_params\":\"%d\"\n},\n", + " \"explanation\":\"%s\",\n \"color_model\":\"%s\",\n" + " \"frei0r_version\":\"%d\",\n \"version\":\"%d.%d\",\n \"num_params\":\"%d\"", pi.name, pi.plugin_type == F0R_PLUGIN_TYPE_FILTER ? "filter" : pi.plugin_type == F0R_PLUGIN_TYPE_SOURCE ? "source" : @@ -43,6 +63,41 @@ int main(int argc, char **argv) { pi.color_model == F0R_COLOR_MODEL_PACKED32 ? "packed32" : "unknown", pi.frei0r_version, pi.major_version, pi.minor_version, pi.num_params); + /* // check icon */ + /* char icon[256]; */ + /* char *dot = rindex(file, '.'); */ + /* *dot = 0x0; */ + /* snprintf(icon,255,"%s/%s.png",dir,file); */ + /* FILE *icon_fd = fopen(icon,"r"); */ + /* if(icon_fd) { */ + /* fprintf(stderr," icon found: %s\n",icon); */ + /* } */ + + // get info about params + if(pi.num_params>0) { + fprintf(stdout,",\n \"params\":[\n"); + for(c=0; cc+1) { + fprintf(stdout,",\n"); + } else { + fprintf(stdout,"\n"); + } + } + fprintf(stdout," ]\n"); + } + fprintf(stdout,"\n},\n"); + fflush(stdout); + f0r_deinit(); dlclose(dl_handle); exit(0); }