diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e5e0fb841..25e9a3890 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ jobs: name: ${{ matrix.os }}_${{ matrix.boost }}_${{ matrix.compiler }}_${{ matrix.geos }} strategy: matrix: - os: [ubuntu, macos] + os: [ubuntu, macos, windows] boost: ['1_66', '1_75'] geos: ['3.8.1', 'none'] compiler: ['g++', 'g++-8', 'clang++'] @@ -26,27 +26,58 @@ jobs: boost: '1_75' - os: macos compiler: 'g++-8' + - os: windows + compiler: 'g++-8' + - os: windows + compiler: 'clang++' + - os: windows + boost: '1_66' include: - os: ubuntu boost: 1_66 compiler: g++-8 geos: '3.8.1' code_coverage: "--enable-code-coverage" + - os: windows + shell: | + powershell -command "[System.Environment]::SetEnvironmentVariable('GITHUB_SCRIPT', ('{0}' -replace '\\','\\')); [System.Environment]::SetEnvironmentVariable('PKG_CONFIG_PATH_MSYS', $Env:PKG_CONFIG_PATH); [System.Environment]::SetEnvironmentVariable('PATH_MSYS', $Env:Path);" + msys2 -c 'if [[ -v MSYSTEM ]]; then sed -i 1d $(cygpath $GITHUB_SCRIPT); sed -i \$d $(cygpath $GITHUB_SCRIPT); if [[ -v PKG_CONFIG_PATH_MSYS ]]; then export PKG_CONFIG_PATH=$PKG_CONFIG_PATH_MSYS; fi; if [[ -v PATH_MSYS && ! ( $PATH_MSYS =~ ^D:\\\\a\\\\_temp\\\\msys\\;C:\\\\Users ) ]]; then export PATH=$(echo $PATH_MSYS | sed s/D:\\\\\\\\a\\\\\\\\_temp\\\\\\\\msys\;// | sed s/\;/:/g); fi; fi; source $(cygpath $GITHUB_SCRIPT)' + local_install_path: '/d/a/pcb2gcode/.local' + - os: ubuntu + shell: bash + local_install_path: '$HOME/.local' + - os: macos + shell: bash + local_install_path: '$HOME/.local' runs-on: ${{ matrix.os }}-latest - + defaults: + run: + shell: ${{ matrix.shell }} steps: + - name: Setup msys2 + if: matrix.os == 'windows' + uses: msys2/setup-msys2@v2 + with: + msystem: MINGW64 + update: true + install: mingw-w64-x86_64-gtkmm git base-devel bash mingw-w64-x86_64-gcc mingw-w64-x86_64-boost mingw-w64-x86_64-cairo - name: Checkout pcb2gcode source uses: actions/checkout@v2 - name: Setup paths and env run: | - mkdir -p $HOME/.local/bin - mkdir -p $HOME/.local/lib/pkgconfig - echo "PKG_CONFIG_PATH=$HOME/.local/lib/pkgconfig:$PKG_CONFIG_PATH" >> $GITHUB_ENV - echo "LD_LIBRARY_PATH=$HOME/.local/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV - echo "PATH=$HOME/.local/bin:$PATH" >> $GITHUB_ENV + mkdir -p ${{ matrix.local_install_path }}/bin + mkdir -p ${{ matrix.local_install_path }}/lib/pkgconfig + echo "PKG_CONFIG_PATH=${{ matrix.local_install_path }}/lib/pkgconfig:$PKG_CONFIG_PATH" >> $GITHUB_ENV + echo "LD_LIBRARY_PATH=${{ matrix.local_install_path }}/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV + echo "PATH=${{ matrix.local_install_path }}/bin:$PATH" >> $GITHUB_ENV + echo "LOCAL_INSTALL_PATH=${{ matrix.local_install_path }}" >> $GITHUB_ENV echo $GITHUB_JSON env: GITHUB_JSON: ${{ toJSON(github) }} + - name: Windows specific setup + if: matrix.os == 'windows' + run: | + echo "NUM_CPUS=$((`nproc --all` * 4))" >> $GITHUB_ENV - name: Ubuntu specific setup if: matrix.os == 'ubuntu' run: | @@ -76,8 +107,8 @@ jobs: brew install boost@1.75 gtkmm moreutils gettext librsvg autoconf automake pkg-config brew upgrade wget hash -r - ln -f -s `which glibtoolize` $HOME/.local/bin/libtoolize - ln -f -s `which glibtool` $HOME/.local/bin/libtool + ln -f -s `which glibtoolize` ${LOCAL_INSTALL_PATH}/bin/libtoolize + ln -f -s `which glibtool` ${LOCAL_INSTALL_PATH}/bin/libtool hash -r echo "BOOST_ROOT=/usr/local/opt/boost@1.75" >> $GITHUB_ENV echo "NUM_CPUS=$((`sysctl -n hw.logicalcpu` * 4))" >> $GITHUB_ENV @@ -91,11 +122,17 @@ jobs: brew install geos - name: Sanitize cache key id: sanitize-key - run: echo "::set-output name=key::$(echo '${{ matrix.os }}_${{ matrix.boost }}_${{ matrix.compiler }}_${{ matrix.geos }}' | sed 's/+/plus/g')" - - name: Cache .local + run: | + echo "::set-output name=key::$(echo '${{ matrix.os }}_${{ matrix.boost }}_${{ matrix.compiler }}_${{ matrix.geos }}' | sed 's/+/plus/g')" + if command -v cygpath; then + echo "::set-output name=path::$(cygpath -w ${{ matrix.local_install_path }})" + else + echo "::set-output name=path::${{ matrix.local_install_path }}" + fi + - name: Cache local install path uses: eyal0/cache@main with: - path: ~/.local + path: ${{ steps.sanitize-key.outputs.path }} key: ${{ steps.sanitize-key.outputs.key }} update-env-variable: "UPDATE_CACHE" - name: Build and install boost @@ -103,7 +140,7 @@ jobs: env: BOOST: ${{ matrix.boost }}_0 run: | - if [ ! -d "${HOME}/.local/include/boost" ]; then + if [ ! -d "${LOCAL_INSTALL_PATH}/include/boost" ]; then echo "UPDATE_CACHE=true" >> $GITHUB_ENV pushd ~ for i in {1..5}; do @@ -111,19 +148,19 @@ jobs: done tar xjf "boost_${BOOST}.tar.bz2" pushd boost_${BOOST} - ./bootstrap.sh --with-libraries=program_options --prefix=${HOME}/.local + ./bootstrap.sh --with-libraries=program_options --prefix=${LOCAL_INSTALL_PATH} ./b2 -j ${NUM_CPUS} ./b2 install popd popd fi - echo "BOOST_ROOT=$(echo ${HOME}/.local)" >> $GITHUB_ENV + echo "BOOST_ROOT=$(echo ${LOCAL_INSTALL_PATH})" >> $GITHUB_ENV - name: Build and install geos - if: matrix.os == 'ubuntu' && matrix.geos != 'none' + if: matrix.os != 'macos' && matrix.geos != 'none' env: GEOS: ${{ matrix.geos }} run: | - if [ ! -d "${HOME}/.local/include/geos" ]; then + if [ ! -d "${LOCAL_INSTALL_PATH}/include/geos" ]; then echo "UPDATE_CACHE=true" >> $GITHUB_ENV pushd ~ for i in {1..5}; do @@ -131,7 +168,7 @@ jobs: done tar xjf "geos-${GEOS}.tar.bz2" pushd geos-${GEOS} - ./configure --prefix=${HOME}/.local + ./configure --prefix=${LOCAL_INSTALL_PATH} make -j ${NUM_CPUS} make install popd @@ -144,7 +181,7 @@ jobs: pushd ~ git clone --depth=1 https://github.com/linux-test-project/lcov.git pushd lcov - make PREFIX=${HOME}/.local install + make PREFIX=${LOCAL_INSTALL_PATH} install hash -r lcov --version - name: Display information about build environment @@ -162,7 +199,7 @@ jobs: git clone --depth=1 https://github.com/eyal0/gerbv.git pushd gerbv sh autogen.sh - ./configure CPPFLAGS=$CPPFLAGS_gerbv --disable-update-desktop-database --prefix=${HOME}/.local + ./configure CPPFLAGS=$CPPFLAGS_gerbv --disable-update-desktop-database --prefix=${LOCAL_INSTALL_PATH} make -j ${NUM_CPUS} make install popd @@ -177,7 +214,7 @@ jobs: git clone --depth=1 git://sourceware.org/git/valgrind.git pushd valgrind sh autogen.sh - ./configure --prefix=${HOME}/.local + ./configure --prefix=${LOCAL_INSTALL_PATH} make -j ${NUM_CPUS} make install popd @@ -195,7 +232,7 @@ jobs: pushd parallel tar xjf "../parallel-latest.tar.bz2" pushd parallel-* - ./configure --prefix=${HOME}/.local + ./configure --prefix=${LOCAL_INSTALL_PATH} make make install popd @@ -244,7 +281,7 @@ jobs: continue-on-error: true run: lcov --directory . -z - name: Run unit tests - if: matrix.os == 'macos' + if: matrix.os != 'ubuntu' env: VERBOSE: 1 SKIP_GERBERIMPORTER_TESTS_PNG: 1 @@ -272,16 +309,17 @@ jobs: with: name: lcov-${{ steps.sanitize-key.outputs.key }} path: pcb2gcode-lcov.info - - name: Prepare build for upload + - name: Prepare build for upload for Ubuntu and Macos + if: matrix.os != 'windows' run: | mkdir pcb2gcode-$(./pcb2gcode --version | head -1) mkdir pcb2gcode-$(./pcb2gcode --version | head -1)/.libs cp ./pcb2gcode pcb2gcode-$(./pcb2gcode --version | head -1) - if [[ -e ~/.local/lib/libgerbv.so.1 ]]; then - cp -L ~/.local/lib/libgerbv.so.1 pcb2gcode-$(./pcb2gcode --version | head -1)/.libs; + if [[ -e ${LOCAL_INSTALL_PATH}/lib/libgerbv.so.1 ]]; then + cp -L ${LOCAL_INSTALL_PATH}/lib/libgerbv.so.1 pcb2gcode-$(./pcb2gcode --version | head -1)/.libs; fi - if [[ -e ~/.local/lib/libgeos-3.8.1.so ]]; then - cp -L ~/.local/lib/libgeos-3.8.1.so pcb2gcode-$(./pcb2gcode --version | head -1)/.libs; + if [[ -e ${LOCAL_INSTALL_PATH}/lib/libgeos-3.8.1.so ]]; then + cp -L ${LOCAL_INSTALL_PATH}/lib/libgeos-3.8.1.so pcb2gcode-$(./pcb2gcode --version | head -1)/.libs; fi cat > pcb2gcode-$(./pcb2gcode --version | head -1)/pcb2gcode.sh << EOF @@ -299,168 +337,8 @@ jobs: chmod a+x pcb2gcode-$(./pcb2gcode --version | head -1)/pcb2gcode.sh tar cvf pcb2gcode-${{ steps.sanitize-key.outputs.key }}.tar pcb2gcode-$(./pcb2gcode --version | head -1) gzip pcb2gcode-${{ steps.sanitize-key.outputs.key }}.tar - - name: Upload build - uses: actions/upload-artifact@v2 - with: - name: pcb2gcode-${{ steps.sanitize-key.outputs.key }} - path: pcb2gcode-${{ steps.sanitize-key.outputs.key }}.tar.gz - - name: Upload coverage to coveralls - if: matrix.code_coverage - uses: coverallsapp/github-action@master - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - path-to-lcov: pcb2gcode-lcov.info - parallel: true - - name: Save version number - if: matrix.code_coverage - run: echo "$(./pcb2gcode --version | head -1)" > version.txt - - name: Upload version artifact - if: matrix.code_coverage - uses: actions/upload-artifact@v2 - with: - name: version - path: version.txt - - build-and-test-windows: - name: ${{ matrix.os }}_${{ matrix.boost }}_${{ matrix.compiler }}_${{ matrix.geos }} - strategy: - matrix: - os: ['windows'] - boost: ['1_75'] - geos: ['3.8.1', 'none'] - compiler: ['g++'] - local_install_path: ['/d/a/pcb2gcode/.local'] - runs-on: ${{ matrix.os }}-latest - - defaults: - run: - shell: | - powershell -command "[System.Environment]::SetEnvironmentVariable('GITHUB_SCRIPT', ('{0}' -replace '\\','\\')); [System.Environment]::SetEnvironmentVariable('PKG_CONFIG_PATH_MSYS', $Env:PKG_CONFIG_PATH); [System.Environment]::SetEnvironmentVariable('PATH_MSYS', $Env:Path);" - msys2 -c 'if [[ -v MSYSTEM ]]; then sed -i 1d $(cygpath $GITHUB_SCRIPT); sed -i \$d $(cygpath $GITHUB_SCRIPT); if [[ -v PKG_CONFIG_PATH_MSYS ]]; then export PKG_CONFIG_PATH=$PKG_CONFIG_PATH_MSYS; fi; if [[ -v PATH_MSYS && ! ( $PATH_MSYS =~ ^D:\\\\a\\\\_temp\\\\msys\\;C:\\\\Users ) ]]; then export PATH=$(echo $PATH_MSYS | sed s/D:\\\\\\\\a\\\\\\\\_temp\\\\\\\\msys\;// | sed s/\;/:/g); fi; fi; source $(cygpath $GITHUB_SCRIPT)' - steps: - - name: Checkout pcb2gcode source - uses: actions/checkout@v2 - - name: Setup msys2 - uses: msys2/setup-msys2@v2 - with: - msystem: MINGW64 - update: true - install: mingw-w64-x86_64-gtkmm git base-devel bash mingw-w64-x86_64-gcc mingw-w64-x86_64-boost mingw-w64-x86_64-cairo - - name: Setup paths and env - run: | - mkdir -p ${LOCAL_INSTALL_PATH}/bin - mkdir -p ${LOCAL_INSTALL_PATH}/lib/pkgconfig - echo "PKG_CONFIG_PATH=${LOCAL_INSTALL_PATH}/lib/pkgconfig:$PKG_CONFIG_PATH" >> $GITHUB_ENV - echo "LD_LIBRARY_PATH=${LOCAL_INSTALL_PATH}/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV - echo "PATH=${LOCAL_INSTALL_PATH}/bin:$PATH" >> $GITHUB_ENV - echo "LOCAL_INSTALL_PATH=${LOCAL_INSTALL_PATH}" >> $GITHUB_ENV - env: - LOCAL_INSTALL_PATH: ${{ matrix.local_install_path }} - - name: Windows specific setup - run: | - echo "NUM_CPUS=$((`nproc --all` * 4))" >> $GITHUB_ENV - - name: Sanitize cache key - id: sanitize-key - run: | - echo "::set-output name=key::$(echo '${{ matrix.os }}_${{ matrix.boost }}_${{ matrix.compiler }}_${{ matrix.geos }}' | sed 's/+/plus/g')" - echo "::set-output name=path::$(cygpath -w ${{ matrix.local_install_path }})" - - name: Cache local install path - uses: eyal0/cache@main - with: - path: ${{ steps.sanitize-key.outputs.path }} - key: ${{ steps.sanitize-key.outputs.key }} - update-env-variable: "UPDATE_CACHE" - - name: Build and install geos - if: matrix.geos != 'none' - env: - GEOS: ${{ matrix.geos }} - run: | - if [ ! -d "${LOCAL_INSTALL_PATH}/include/geos" ]; then - echo "UPDATE_CACHE=true" >> $GITHUB_ENV - pushd ~ - for i in {1..5}; do - wget -q -T20 -t1 -O "geos-${GEOS}.tar.bz2" "http://download.osgeo.org/geos/geos-${GEOS}.tar.bz2" && break; - done - tar xjf "geos-${GEOS}.tar.bz2" - pushd geos-${GEOS} - ./configure --prefix=${LOCAL_INSTALL_PATH} - make -j ${NUM_CPUS} - make install - popd - popd - fi - - name: Display information about build environment - continue-on-error: true - run: | - env - if command -v g++; then g++ --version; fi - if command -v clang++; then clang++ --version; fi - if command -v pkg-config; then pkg-config --version; fi - if command -v m4; then m4 --version; fi - - name: Install gerbv - run: | - if ! gerbv --version; then - echo "UPDATE_CACHE=true" >> $GITHUB_ENV - pushd ~ - git clone --depth=1 https://github.com/eyal0/gerbv.git - pushd gerbv - sh autogen.sh - ./configure CPPFLAGS=$CPPFLAGS_gerbv --disable-update-desktop-database --prefix=${LOCAL_INSTALL_PATH} - make -j ${NUM_CPUS} - make install - popd - popd - fi - - name: Install parallel - run: | - if ! parallel --version; then - echo "UPDATE_CACHE=true" >> $GITHUB_ENV - pushd ~ - for i in {1..5}; do - wget -q -T5 -t1 -O "parallel-latest.tar.bz2" "http://ftpmirror.gnu.org/parallel/parallel-latest.tar.bz2" && break; - done - mkdir parallel - pushd parallel - tar xjf "../parallel-latest.tar.bz2" - pushd parallel-* - ./configure --prefix=${LOCAL_INSTALL_PATH} - make - make install - popd - popd - popd - fi - - name: Finalize setup - run: | - hash -r - - name: Autoreconf pcb2gcode - run: autoreconf -fvi - - name: Configure pcb2gcode - run: >- - ./configure pcb2gcode_CPPFLAGS_EXTRA=-Werror - --disable-dependency-tracking - --disable-silent-rules - --enable-static-boost - --enable-static - ${{ matrix.code_coverage }} - || (cat config.log && false) - - name: Make pcb2gcode - run: make -j ${NUM_CPUS} - - name: Run examples - if: '! matrix.code_coverage' - run: | - pushd testing/gerbv_example - ls | parallel -k -j ${NUM_CPUS} --halt soon,fail=1 ' - pushd {}; - echo "Running on {}"; - if [[ -f "no-valgrind" ]]; then - cat no-valgrind; - fi; - time ../../../pcb2gcode || exit; - echo "Finished on {}"; - popd' - popd - - name: Prepare build for upload + - name: Prepare build for upload for Windows + if: matrix.os == 'windows' run: | mkdir pcb2gcode-$(./pcb2gcode --version | head -1) pushd pcb2gcode-$(./pcb2gcode --version | head -1) @@ -510,20 +388,40 @@ jobs: tar cvf pcb2gcode-${{ steps.sanitize-key.outputs.key }}.tar pcb2gcode-$(./pcb2gcode --version | head -1) env: GEOS: ${{ matrix.geos }} - - name: Upload build + - name: Upload build for Ubuntu and Macos + if: matrix.os != 'windows' + uses: actions/upload-artifact@v2 + with: + name: pcb2gcode-${{ steps.sanitize-key.outputs.key }} + path: pcb2gcode-${{ steps.sanitize-key.outputs.key }}.tar.gz + - name: Upload build for Windows + if: matrix.os == 'windows' uses: actions/upload-artifact@v2 with: name: pcb2gcode-${{ steps.sanitize-key.outputs.key }} path: pcb2gcode-${{ steps.sanitize-key.outputs.key }}.tar + - name: Upload coverage to coveralls + if: matrix.code_coverage + uses: coverallsapp/github-action@master + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + path-to-lcov: pcb2gcode-lcov.info + parallel: true + - name: Save version number + if: matrix.code_coverage + run: echo "$(./pcb2gcode --version | head -1)" > version.txt + - name: Upload version artifact + if: matrix.code_coverage + uses: actions/upload-artifact@v2 + with: + name: version + path: version.txt + finalize-coverage: - needs: [build-and-test, build-and-test-windows] + needs: [build-and-test] name: Finalize coverage runs-on: ubuntu-latest steps: - - name: Checkout pcb2gcode source - uses: actions/checkout@v2 - with: - fetch-depth: 2 - name: Finalize coverage uses: coverallsapp/github-action@master with: @@ -531,7 +429,7 @@ jobs: parallel-finished: true release: if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')) - needs: [build-and-test, build-and-test-windows] + needs: [build-and-test] name: release runs-on: ubuntu-latest steps: