diff --git a/.github/CI.md b/.github/CI.md index d9c0d06a2..d69898120 100644 --- a/.github/CI.md +++ b/.github/CI.md @@ -15,3 +15,8 @@ configuration, click on the corresponding badge below. | ![Full version MS-MPI](https://github.com/FreeFem/FreeFem-sources/actions/workflows/full-msmpi.yml/badge.svg) | ![Full version MS-MPI](https://github.com/FreeFem/FreeFem-sources/actions/workflows/full-msmpi.yml/badge.svg?branch=develop) | GitHub Actions workflows definition files available [here](.github/workflows). + +## Triggers + +CI worklows are triggered whenever there is a **push on develop or master** +branches, or when creating a **pull request on develop** branch. diff --git a/.github/workflows/full-mpich.yml b/.github/workflows/full-mpich.yml index 8e966db53..d1b5aade7 100644 --- a/.github/workflows/full-mpich.yml +++ b/.github/workflows/full-mpich.yml @@ -11,6 +11,31 @@ on: branches: - develop + workflow_call: + inputs: + build-types: + description: 'Build types as JSON array' + required: false + type: string + default: '["debug", "release"]' + versions: + description: 'Ubuntu version as JSON array' + required: false + type: string + default: '[22.04, 24.04]' + skip_check: + required: false + type: boolean + default: false + skip_macos: + required: false + type: boolean + default: false + upload_build_artifacts: + required: false + type: boolean + default: false + # For development phase workflow_dispatch: @@ -23,37 +48,45 @@ jobs: strategy: fail-fast: false matrix: - version: [22.04, 24.04] - cfg: - - {opts: --enable-debug} - - {opts: --enable-optim --enable-generic} + version: ${{ fromJson(inputs.versions || '[22.04, 24.04]') }} + build-type: ${{ fromJson(inputs.build-types || '["debug", "release"]') }} - name: Ubuntu ${{ matrix.version }} with ${{ matrix.cfg.opts }} \ + name: Ubuntu ${{ matrix.version }} with ${{ matrix.build-type }} \ - ${{ github.workflow }} - + env: + INSTALL_DIR: /usr/local runs-on: ubuntu-${{ matrix.version }} - steps: - uses: actions/checkout@v4 - - name: Install + - name: Install dependencies run: | sudo apt update - sudo apt install gcc g++ gfortran m4 patch git wget cmake \ - libhdf5-dev flex bison autoconf automake \ - autotools-dev + sudo apt install -y gcc g++ gfortran m4 patch git wget cmake \ + libhdf5-dev flex bison autoconf automake unzip patch \ + autotools-dev python3 freeglut3-dev + + - name: Set configure flags and variables + id: flags + run: | + if [ "${{ matrix.build-type }}" = "debug" ]; then + echo "configure-flags=--enable-debug" >> $GITHUB_OUTPUT + elif [ "${{ matrix.build-type }}" = "release" ]; then + echo "configure-flags=--enable-optim --enable-generic" >> $GITHUB_OUTPUT + fi + echo "staging-dir=${{ github.workspace }}/install_staging" >> $GITHUB_OUTPUT - name: Configure run: | autoreconf -i - ./configure --enable-download ${{ matrix.cfg.opts }} \ - --prefix="${HOME}/freefem" + ./configure --enable-download ${{ steps.flags.outputs.configure-flags }} \ + --prefix="$INSTALL_DIR" ./3rdparty/getall -a -o PETSc - name: PETSc run: | cd 3rdparty/ff-petsc - make petsc-slepc + sudo make petsc-slepc cd - ./reconfigure @@ -67,22 +100,43 @@ jobs: config.log compression-level: 9 + # Weird problem of permission on libfftw3.la without sudo - name: Build - run: make -j 4 + run: sudo make -j 4 - name: Check + if: ${{ inputs.skip_check == false }} run: | make check -i ./etc/actions/failed_tests_logs.sh - - name: Install - run: make install + - name: Install to staging directory + if: ${{ inputs.upload_build_artifacts == true }} + run: | + mkdir -p ${{ steps.flags.outputs.staging-dir }}/$INSTALL_DIR + sudo make install DESTDIR=${{ steps.flags.outputs.staging-dir }} + sudo cp -r $INSTALL_DIR/ff-petsc ${{ steps.flags.outputs.staging-dir }}/$INSTALL_DIR + + - name: Tar to keep permission when upload/download + if: ${{ inputs.upload_build_artifacts == true }} + run: | + cd ${{ steps.flags.outputs.staging-dir }}/${{ env.INSTALL_DIR }} + tar -czf ${{ github.workspace }}/install_tree.tar.gz . + + - name: Upload + if: ${{ inputs.upload_build_artifacts == true }} + uses: actions/upload-artifact@v4 + with: + name: install_tree_${{ matrix.version }} + path: install_tree.tar.gz + retention-days: 1 macos: + if: ${{ inputs.skip_macos == false }} strategy: fail-fast: false matrix: - version: [13, 14, 15] + version: [14, 15] cfg: - {opts: --enable-debug} - {opts: --enable-optim --enable-generic} diff --git a/.github/workflows/full-openmpi.yml b/.github/workflows/full-openmpi.yml index e65886f44..39545d406 100644 --- a/.github/workflows/full-openmpi.yml +++ b/.github/workflows/full-openmpi.yml @@ -11,6 +11,27 @@ on: branches: - develop + workflow_call: + inputs: + build-types: + description: 'Build types as JSON array' + required: false + type: string + default: '["debug", "release"]' + versions: + description: 'Ubuntu version as JSON array' + required: false + type: string + default: '[22.04, 24.04]' + skip_check: + required: false + type: boolean + default: false + upload_build_artifacts: + required: false + type: boolean + default: false + # For development phase workflow_dispatch: @@ -23,37 +44,45 @@ jobs: strategy: fail-fast: false matrix: - version: [22.04, 24.04] - cfg: - - {opts: --enable-debug} - - {opts: --enable-optim --enable-generic} + version: ${{ fromJson(inputs.versions || '[22.04, 24.04]') }} + build-type: ${{ fromJson(inputs.build-types || '["debug", "release"]') }} - name: Ubuntu ${{ matrix.version }} with ${{ matrix.cfg.opts }} \ + name: Ubuntu ${{ matrix.version }} with ${{ matrix.build-type }} \ - ${{ github.workflow }} - + env: + INSTALL_DIR: /usr/local runs-on: ubuntu-${{ matrix.version }} - steps: - uses: actions/checkout@v4 - - name: Install + - name: Install dependencies run: | sudo apt update - sudo apt install gcc g++ gfortran m4 patch git wget cmake \ - libhdf5-dev flex bison autoconf automake \ - autotools-dev libopenmpi-dev + sudo apt install -y gcc g++ gfortran m4 patch git wget cmake \ + libhdf5-dev flex bison autoconf automake unzip patch \ + autotools-dev libopenmpi-dev python3 freeglut3-dev + + - name: Set configure flags and variables + id: flags + run: | + if [ "${{ matrix.build-type }}" = "debug" ]; then + echo "configure-flags=--enable-debug" >> $GITHUB_OUTPUT + elif [ "${{ matrix.build-type }}" = "release" ]; then + echo "configure-flags=--enable-optim --enable-generic" >> $GITHUB_OUTPUT + fi + echo "staging-dir=${{ github.workspace }}/install_staging" >> $GITHUB_OUTPUT - name: Configure run: | autoreconf -i - ./configure --enable-download ${{ matrix.cfg.opts }} \ - --prefix="${HOME}/freefem" + ./configure --enable-download ${{ steps.flags.outputs.configure-flags }} \ + --prefix="$INSTALL_DIR" ./3rdparty/getall -a -o PETSc - name: PETSc run: | cd 3rdparty/ff-petsc - make petsc-slepc + sudo make petsc-slepc cd - ./reconfigure @@ -67,15 +96,35 @@ jobs: config.log compression-level: 9 + # Weird problem of permission on libfftw3.la without sudo - name: Build - run: make -j 4 + run: sudo make -j 4 - name: Check + if: ${{ inputs.skip_check == false }} run: | make check -i ./etc/actions/failed_tests_logs.sh - - name: Install - run: make install + - name: Install to staging directory + if: ${{ inputs.upload_build_artifacts == true }} + run: | + mkdir -p ${{ steps.flags.outputs.staging-dir }}/$INSTALL_DIR + sudo make install DESTDIR=${{ steps.flags.outputs.staging-dir }} + sudo cp -r $INSTALL_DIR/ff-petsc ${{ steps.flags.outputs.staging-dir }}/$INSTALL_DIR + + - name: Tar to keep permission when upload/download + if: ${{ inputs.upload_build_artifacts == true }} + run: | + cd ${{ steps.flags.outputs.staging-dir }}/${{ env.INSTALL_DIR }} + tar -czf ${{ github.workspace }}/install_tree.tar.gz . + + - name: Upload + if: ${{ inputs.upload_build_artifacts == true }} + uses: actions/upload-artifact@v4 + with: + name: install_tree_${{ matrix.version }} + path: install_tree.tar.gz + retention-days: 1 # No test for macOS, the homebrew bottle open-mpi seems broken. diff --git a/.github/workflows/minimal.yml b/.github/workflows/minimal.yml index 75d189697..f7c045f85 100644 --- a/.github/workflows/minimal.yml +++ b/.github/workflows/minimal.yml @@ -58,7 +58,7 @@ jobs: strategy: fail-fast: false matrix: - version: [13, 14, 15] + version: [14, 15] cfg: - {opts: --enable-debug} - {opts: --enable-optim --enable-generic} diff --git a/.github/workflows/release_deb.yml b/.github/workflows/release_deb.yml new file mode 100644 index 000000000..0bf36d62b --- /dev/null +++ b/.github/workflows/release_deb.yml @@ -0,0 +1,128 @@ +# Call the corresponding build workflow with the proper arguments: +# - Build_type: Release +# - Upload build_tree: true +name: Release DEB + +on: + push: + tags: + - 'v*' + +jobs: + build_freefem: + uses: ./.github/workflows/full-mpich.yml + with: + versions: '[22.04, 24.04]' + build-types: '["release"]' + skip_check: true + skip_macos: true + upload_build_artifacts: true + + package_freefem_2204: + needs: build_freefem + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + + - name: Extract version, tag and .deb file name + id: version + run: | + VERSION=$(grep AC_INIT configure.ac | cut -d"," -f2 | cut -d"[" -f2 | cut -d"]" -f1) + RELEASE_TAG_NAME="v$VERSION" + OSRELEASE=$(lsb_release -r|awk '{print $2}') + GH_DEB_NAME="FreeFEM-${VERSION}-amd64-ubuntu${OSRELEASE}.deb" + echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "release_tag_name=$RELEASE_TAG_NAME" >> $GITHUB_OUTPUT + echo "gh_deb_name=$GH_DEB_NAME" >> $GITHUB_OUTPUT + echo "Version: $VERSION" + echo "Release tag name: $RELEASE_TAG_NAME" + echo "Package name: $GH_DEB_NAME" + + - uses: actions/download-artifact@v5 + with: + name: install_tree_22.04 + path: ./artifacts + github-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Untar artifact and package .deb + run: | + mkdir ./install_tree + tar -xzf ./artifacts/install_tree.tar.gz -C ./install_tree/ + bash etc/actions/releases/package_deb_ubuntu.sh \ + ./install_tree \ + ${{ steps.version.outputs.version }} + + - name: Upload .deb as artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ steps.version.outputs.release_tag_name }}-22.04 + path: ./*.deb + + package_freefem_2404: + needs: build_freefem + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + + - name: Extract version, tag and .deb file name + id: version + run: | + VERSION=$(grep AC_INIT configure.ac | cut -d"," -f2 | cut -d"[" -f2 | cut -d"]" -f1) + RELEASE_TAG_NAME="v$VERSION" + OSRELEASE=$(lsb_release -r|awk '{print $2}') + GH_DEB_NAME="FreeFEM-${VERSION}-amd64-ubuntu${OSRELEASE}.deb" + echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "release_tag_name=$RELEASE_TAG_NAME" >> $GITHUB_OUTPUT + echo "gh_deb_name=$GH_DEB_NAME" >> $GITHUB_OUTPUT + echo "Version: $VERSION" + echo "Release tag name: $RELEASE_TAG_NAME" + echo "Package name: $GH_DEB_NAME" + + - uses: actions/download-artifact@v5 + with: + name: install_tree_24.04 + path: ./artifacts + github-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Unta artifact and package .deb + run: | + mkdir ./install_tree + tar -xzf ./artifacts/install_tree.tar.gz -C ./install_tree/ + bash etc/actions/releases/package_deb_ubuntu.sh \ + ./install_tree \ + ${{ steps.version.outputs.version }} + + - name: Upload .deb as artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ steps.version.outputs.release_tag_name }}-24.04 + path: ./*.deb + + + create_release: + needs: [package_freefem_2204, package_freefem_2404] + runs-on: ubuntu-latest + permissions: + contents: write # Required to create releases + steps: + - name: Download all .deb packages + uses: actions/download-artifact@v4 + with: + path: ./release-assets + merge-multiple: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Untar the artifact + run: find ./release-assets -name "*.tar.gz" -exec tar -xzf {} -C ./release-assets \; + + - name: Create Release + uses: softprops/action-gh-release@v1 + with: + files: ./release-assets/*.deb + draft: false + prerelease: false + # generate_release_notes: true + tag_name: ${{ github.ref_name }} # Should automatically uses the tag + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/sequential.yml b/.github/workflows/sequential.yml index 61e3f4dfb..f970682e1 100644 --- a/.github/workflows/sequential.yml +++ b/.github/workflows/sequential.yml @@ -60,7 +60,7 @@ jobs: strategy: fail-fast: false matrix: - version: [13, 14, 15] + version: [14, 15] cfg: - {opts: --enable-debug} - {opts: --enable-optim --enable-generic} diff --git a/etc/actions/releases/package_deb_ubuntu.sh b/etc/actions/releases/package_deb_ubuntu.sh new file mode 100644 index 000000000..ad52da121 --- /dev/null +++ b/etc/actions/releases/package_deb_ubuntu.sh @@ -0,0 +1,67 @@ +#!/usr/bin/env bash + +# Provided install tree (DESTDIR/usr/local) of FreeFEM, this scripts builds a DEB +# package of FreeFem and store it in GH_DEB_NAME +# +# Example for v4.16 on Ubuntu 24.04: +# FreeFEM-4.16-amd64-ubuntu24.04.deb + +set -x +set -u +set -e + +## Parameters + +INSTALL_TREE=$1 +VERSION=$2 + +# TOKEN=$1 +#ORGANIZATION="simonlegrand" +REPOSITORY="FreeFem-sources" +#VERSION=$(grep AC_INIT configure.ac | cut -d"," -f2 | cut -d"[" -f2 | cut -d"]" -f1) +#RELEASE_TAG_NAME="v$VERSION" +OSRELEASE=$(lsb_release -r|awk '{print $2}') + + +DEB_NAME="freefem-${VERSION}-amd64-ubuntu${OSRELEASE}" +GH_DEB_NAME="FreeFEM-${VERSION}-amd64-ubuntu${OSRELEASE}.deb" + +## Create FreeFEM Debian package +mkdir "$DEB_NAME" +mkdir "$DEB_NAME/DEBIAN" +touch "$DEB_NAME/DEBIAN/control" +{ + echo "Package: freefem"; + echo "Version: $VERSION"; + echo "Section: custom"; + echo "Architecture: amd64"; + echo "Depends: libc6 (>= 2.31), g++ (>= 9.3), gcc (>= 9.3), gfortran (>= 9.3), libgsl-dev (>=2.5), libhdf5-dev (>=1.10.4), liblapack-dev (>= 3.9), freeglut3-dev (>= 2.8.1)"; + echo "Maintainer: FreeFEM, Frédéric Hecht "; + echo "Description: FreeFEM, Finite Element Language software"; + echo "Homepage: https://freefem.org" +} >> "$DEB_NAME/DEBIAN/control" +mkdir -p "$DEB_NAME/usr/local/share/FreeFEM" +mkdir -p "$DEB_NAME/usr/local/bin" +mkdir -p "$DEB_NAME/usr/local/lib/ff++" +mkdir -p "$DEB_NAME/usr/share/doc/freefem" + +cp -r "$INSTALL_TREE/lib/ff++/$VERSION" "$DEB_NAME/usr/local/lib/ff++/$VERSION" +cp -r "$INSTALL_TREE/ff-petsc/" "$DEB_NAME/usr/local/ff-petsc" +cp -r "$INSTALL_TREE/share/FreeFEM/$VERSION" "$DEB_NAME/usr/local/share/FreeFEM/$VERSION" +cp -r "$INSTALL_TREE/bin/FreeFem++" "$DEB_NAME/usr/local/bin/FreeFem++" +cp -r "$INSTALL_TREE/bin/FreeFem++-mpi" "$DEB_NAME/usr/local/bin/FreeFem++-mpi" +cp -r "$INSTALL_TREE/bin/FreeFem++-nw" "$DEB_NAME/usr/local/bin/FreeFem++-nw" +cp -r "$INSTALL_TREE/bin/bamg" "$DEB_NAME/usr/local/bin/bamg" +cp -r "$INSTALL_TREE/bin/cvmsh2" "$DEB_NAME/usr/local/bin/cvmsh2" +cp -r "$INSTALL_TREE/bin/ff-c++" "$DEB_NAME/usr/local/bin/ff-c++" +cp -r "$INSTALL_TREE/bin/ff-get-dep" "$DEB_NAME/usr/local/bin/ff-get-dep" +cp -r "$INSTALL_TREE/bin/ff-mpirun" "$DEB_NAME/usr/local/bin/ff-mpirun" +cp -r "$INSTALL_TREE/bin/ff-pkg-download" "$DEB_NAME/usr/local/bin/ff-pkg-download" +cp -r "$INSTALL_TREE/bin/ffglut" "$DEB_NAME/usr/local/bin/ffglut" +cp -r "$INSTALL_TREE/bin/ffmaster" "$DEB_NAME/usr/local/bin/ffmaster" +cp -r "$INSTALL_TREE/bin/ffmedit" "$DEB_NAME/usr/local/bin/ffmedit" +cp AUTHORS "$DEB_NAME/usr/share/doc/freefem/AUTHOR" +cp README.md "$DEB_NAME/usr/share/doc/freefem/README.md" + +dpkg-deb --build "$DEB_NAME/" +mv "$DEB_NAME.deb" "$GH_DEB_NAME"