diff --git a/.github/workflows/cmake-ctest.yml b/.github/workflows/cmake-ctest.yml new file mode 100644 index 00000000..5d327d76 --- /dev/null +++ b/.github/workflows/cmake-ctest.yml @@ -0,0 +1,240 @@ +name: hdf5 examples ctest runs + +# Controls when the action will run. Triggers the workflow on a schedule +on: + workflow_call: + inputs: + hdf5-name: + description: "The hdf5 base name of the binaries" + required: true + type: string + file_base: + description: "The common base name of the source tarballs" + required: true + type: string + +permissions: + contents: read + +# A workflow run is made up of one or more jobs that can run sequentially or +# in parallel +jobs: + build_and_test_win: + # Windows w/ MSVC + CMake + # + name: "Windows MSVC CTest" + runs-on: windows-latest + steps: + - name: Install Dependencies (Windows) + run: choco install ninja + + - uses: actions/checkout@v3 + + - name: Set up JDK 19 + uses: actions/setup-java@v3 + with: + java-version: '19' + distribution: 'temurin' + + - name: Enable Developer Command Prompt + uses: ilammy/msvc-dev-cmd@v1.12.1 + + - name: Get hdf5 release + uses: dsaltares/fetch-gh-release-asset@master + with: + repo: 'HDFGroup/hdf5' + #version: 'tags/1.14.2' + #file: 'hdf5-1_14_2-win_vs2022.zip' + version: 'tags/snapshot' + file: '${{ needs.get-base-names.outputs.hdf5-name }}-win_vs2022.zip' + + - name: Uncompress gh binary (Win) + run: 7z x ${{ github.workspace }}/${{ needs.get-base-names.outputs.hdf5-name }}-win_vs2022.zip + + - name: Uncompress hdf5 binary (Win) + working-directory: ${{ github.workspace }}/hdf5 + run: 7z x HDF5-*-win64.zip + shell: bash + + - name: List files for the space (Win) + run: | + ls -l ${{ github.workspace }}/hdf5 + ls ${{ runner.workspace }}/hdfview + + - name: create hdf5 location (Win) + working-directory: ${{ github.workspace }}/hdf5 + run: | + New-Item -Path "${{ github.workspace }}/HDF_Group/HDF5" -ItemType Directory + Copy-Item -Path "${{ github.workspace }}/hdf5/HDF*/*" -Destination "${{ github.workspace }}/HDF_Group/HDF5" -Recurse + shell: pwsh + + - name: List files for the space (Win) + run: ls -l ${{ github.workspace }}/HDF_Group/HDF5 + + - name: set hdf5lib name + id: set-hdf5lib-name + run: | + HDF5DIR="${{ github.workspace }}/HDF_Group/HDF5" + echo "HDF5_ROOT=$HDF5DIR$FILE_NAME_HDF5" >> $GITHUB_OUTPUT + echo "HDF5_PLUGIN_PATH=$HDF5_ROOT/lib/plugin" >> $GITHUB_OUTPUT + shell: bash + + - name: List files for the binaries (Win) + run: | + ls -l ${{ github.workspace }}/HDF_Group/HDF + ls -l ${{ github.workspace }}/HDF_Group/HDF5 + + - name: Set file base name (Windows) + id: set-file-base + run: | + FILE_NAME_BASE=$(echo "${{ inputs.file_base }}") + echo "FILE_BASE=$FILE_NAME_BASE" >> $GITHUB_OUTPUT + shell: bash + + # Get files created by release script + - name: Get zip-tarball (Windows) + uses: actions/download-artifact@v3 + with: + name: zip-tarball + path: ${{ github.workspace }} + + - name: using powershell + shell: pwsh + run: Get-Location + + - name: List files for the space (Windows) + run: | + Get-ChildItem -Path ${{ github.workspace }} + Get-ChildItem -Path ${{ runner.workspace }} + shell: pwsh + + - name: Uncompress source (Windows) + working-directory: ${{ github.workspace }} + run: 7z x ${{ steps.set-file-base.outputs.FILE_BASE }}.zip + shell: bash + + - name: Run ctest (Windows) + run: | + cd "${{ runner.workspace }}/hdf-examples/hdfsrc" + cmake --workflow --preset=ci-StdShar-MSVC --fresh + shell: bash + + build_and_test_linux: + # Linux (Ubuntu) w/ gcc + CMake + # + name: "Ubuntu gcc CMake" + runs-on: ubuntu-latest + steps: + - name: Install CMake Dependencies (Linux) + run: sudo apt-get install ninja-build doxygen graphviz + + - uses: actions/checkout@v3 + + - name: Set up JDK 19 + uses: actions/setup-java@v3 + with: + java-version: '19' + distribution: 'temurin' + + - name: Get hdf5 release + uses: dsaltares/fetch-gh-release-asset@master + with: + repo: 'HDFGroup/hdf5' + #version: 'tags/1.14.2' + #file: 'hdf5-1_14_2-ubuntu-2204.tar.gz' + version: 'tags/snapshot' + file: '${{ needs.get-base-names.outputs.hdf5-name }}-ubuntu-2204.tar.gz' + + - name: List files for the space (Linux) + run: | + ls -l ${{ github.workspace }} + ls ${{ runner.workspace }} + + - name: Uncompress gh binary (Linux) + run: tar -zxvf ${{ github.workspace }}/${{ needs.get-base-names.outputs.hdf5-name }}-ubuntu-2204.tar.gz + + - name: Uncompress hdf5 binary (Linux) + run: | + cd "${{ github.workspace }}/hdf5" + tar -zxvf ${{ github.workspace }}/hdf5/HDF5-*-Linux.tar.gz --strip-components 1 + + - name: set hdf5lib name + id: set-hdf5lib-name + run: | + HDF5DIR=${{ github.workspace }}/hdf5/HDF_Group/HDF5/ + FILE_NAME_HDF5=$(ls ${{ github.workspace }}/hdf5/HDF_Group/HDF5) + echo "HDF5_ROOT=$HDF5DIR$FILE_NAME_HDF5" >> $GITHUB_OUTPUT + echo "HDF5_PLUGIN_PATH=$HDF5_ROOT/lib/plugin" >> $GITHUB_OUTPUT + + - name: List files for the binaries (Linux) + run: | + ls -l ${{ github.workspace }}/hdf5/HDF_Group/HDF5 + + - name: Set file base name (Linux) + id: set-file-base + run: | + FILE_NAME_BASE=$(echo "${{ inputs.file_base }}") + echo "FILE_BASE=$FILE_NAME_BASE" >> $GITHUB_OUTPUT + + # Get files created by release script + - name: Get tgz-tarball (Linux) + uses: actions/download-artifact@v3 + with: + name: tgz-tarball + path: ${{ github.workspace }} + + - name: List files for the space (Linux) + run: | + ls -l ${{ github.workspace }} + ls ${{ runner.workspace }} + + - name: Uncompress source (Linux) + run: tar -zxvf ${{ github.workspace }}/${{ steps.set-file-base.outputs.FILE_BASE }}.tar.gz + + - name: Run ctest (Linux) + run: | + cd "${{ runner.workspace }}/hdf-examples/hdfsrc" + cmake --workflow --preset=ci-StdShar-GNUC --fresh + shell: bash + + build_and_test_mac: + # MacOS w/ Clang + CMake + # + name: "MacOS Clang CMake" + runs-on: macos-11 + steps: + - name: Install Dependencies (MacOS) + run: brew install ninja doxygen + + - name: Set file base name (MacOS) + id: set-file-base + run: | + FILE_NAME_BASE=$(echo "${{ inputs.file_base }}") + echo "FILE_BASE=$FILE_NAME_BASE" >> $GITHUB_OUTPUT + + # Get files created by release script + - name: Get tgz-tarball (MacOS) + uses: actions/download-artifact@v3 + with: + name: tgz-tarball + path: ${{ github.workspace }} + + - name: List files for the space (MacOS) + run: | + ls ${{ github.workspace }} + ls ${{ runner.workspace }} + + - name: Uncompress source (MacOS) + run: tar -zxvf ${{ github.workspace }}/${{ steps.set-file-base.outputs.FILE_BASE }}.tar.gz + + # symlinks the compiler executables to a common location + - name: Setup GNU Fortran + uses: modflowpy/install-gfortran-action@v1 + + - name: Run ctest (MacOS) + id: run-ctest + run: | + cd "${{ runner.workspace }}/hdf5/hdfsrc" + cmake --workflow --preset=ci-StdShar-Clang --fresh + shell: bash + diff --git a/.github/workflows/daily-build.yml b/.github/workflows/daily-build.yml new file mode 100644 index 00000000..bdea0a25 --- /dev/null +++ b/.github/workflows/daily-build.yml @@ -0,0 +1,64 @@ +name: hdf5 examples daily build + +# Controls when the action will run. Triggers the workflow on a schedule +on: + workflow_dispatch: +# push: +# branches: [ "master" ] + pull_request: + branches: [ "master" ] + +permissions: + contents: read + +# A workflow run is made up of one or more jobs that can run sequentially or +# in parallel. +jobs: + get-base-names: + runs-on: ubuntu-latest + outputs: + hdf5-name: ${{ steps.gethdf5base.outputs.HDF5_NAME_BASE }} + + steps: + - uses: actions/checkout@v3 + + - name: Get hdf5 release base name + uses: dsaltares/fetch-gh-release-asset@master + with: + repo: 'HDFGroup/hdf5' + version: 'tags/snapshot' + file: 'last-file.txt' + + - name: Read base-name file + id: gethdf5base + run: echo "HDF5_NAME_BASE=$(cat last-file.txt)" >> $GITHUB_OUTPUT + + call-workflow-tarball: + uses: ./.github/workflows/tarball.yml + with: + #use_tag: snapshot + use_environ: snapshots + + call-workflow-ctest: + needs: [get-base-names, call-workflow-tarball] + uses: ./.github/workflows/cmake-ctest.yml + with: + file_base: ${{ needs.call-workflow-tarball.outputs.file_base }} + use_hdf: ${{ needs.get-base-names.outputs.hdf5-name }} + #use_tag: snapshot + #use_environ: snapshots + if: ${{ needs.call-workflow-tarball.outputs.has_changes == 'true' }} + + call-workflow-release: + needs: [call-workflow-tarball, call-workflow-ctest] + permissions: + contents: write # In order to allow tag creation + uses: ./.github/workflows/release-files.yml + with: + file_base: ${{ needs.call-workflow-tarball.outputs.file_base }} + file_branch: ${{ needs.call-workflow-tarball.outputs.file_branch }} + file_sha: ${{ needs.call-workflow-tarball.outputs.file_sha }} + use_tag: snapshot + use_environ: snapshots + if: ${{ needs.call-workflow-tarball.outputs.has_changes == 'true' }} + diff --git a/.github/workflows/release-files.yml b/.github/workflows/release-files.yml new file mode 100644 index 00000000..9f692dc7 --- /dev/null +++ b/.github/workflows/release-files.yml @@ -0,0 +1,148 @@ +name: hdf5 examples release-files + +# Controls when the action will run. Triggers the workflow on a schedule +on: + workflow_call: + inputs: + use_tag: + description: 'Release version tag' + type: string + required: false + default: snapshot + use_environ: + description: 'Environment to locate files' + type: string + required: true + default: snapshots + file_base: + description: "The common base name of the source tarballs" + required: true + type: string + file_branch: + description: "The branch name for the source tarballs" + required: true + type: string + file_sha: + description: "The sha for the source tarballs" + required: true + type: string + +# Minimal permissions to be inherited by any job that doesn't declare its own permissions +permissions: + contents: read + +# Previous workflows must pass to get here so tag the commit that created the files +jobs: + create-tag: + runs-on: ubuntu-latest + permissions: + contents: write # In order to allow tag creation + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - name: Get Sources + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - run: | + git checkout ${{ inputs.file_sha }} + + - uses: rickstaa/action-create-tag@v1 + id: "tag_create" + with: + commit_sha: ${{ inputs.file_sha }} + tag: "${{ inputs.use_tag }}" + force_push_tag: true + message: "Latest snapshot" + if: ${{ inputs.use_environ == 'snapshots' }} + + # Print result using the action output. + - run: | + echo "Tag already present: ${{ steps.tag_create.outputs.tag_exists }}" + + PreRelease-getfiles: + runs-on: ubuntu-latest + needs: create-tag + environment: ${{ inputs.use_environ }} + permissions: + contents: write + steps: + - name: Get file base name + id: get-file-base + run: | + FILE_NAME_BASE=$(echo "${{ inputs.file_base }}") + echo "FILE_BASE=$FILE_NAME_BASE" >> $GITHUB_OUTPUT + + # Get files created by tarball script + - name: Get tgz-tarball (Linux) + uses: actions/download-artifact@v3 + with: + name: tgz-tarball + path: ${{ github.workspace }} + + - name: Get zip-tarball (Windows) + uses: actions/download-artifact@v3 + with: + name: zip-tarball + path: ${{ github.workspace }} + + # Get files created by cmake-ctest script + - name: Get published binary (Windows) + uses: actions/download-artifact@v3 + with: + name: zip-vs2022-binary + path: ${{ github.workspace }} + + - name: Get published binary (MacOS) + uses: actions/download-artifact@v3 + with: + name: tgz-osx12-binary + path: ${{ github.workspace }} + + - name: Get published binary (Linux) + uses: actions/download-artifact@v3 + with: + name: tgz-ubuntu-2204-binary + path: ${{ github.workspace }} + + - name: Store snapshot name + run: | + echo "${{ steps.get-file-base.outputs.FILE_BASE }}" > ./last-file.txt + + - name: PreRelease tag + id: create_prerelease + if: ${{ (inputs.use_environ == 'snapshots') }} + uses: softprops/action-gh-release@v1 + with: + tag_name: "${{ inputs.use_tag }}" + prerelease: true + files: | + last-file.txt + ${{ steps.get-file-base.outputs.FILE_BASE }}.tar.gz + ${{ steps.get-file-base.outputs.FILE_BASE }}.zip + ${{ steps.get-file-base.outputs.FILE_BASE }}-osx12.tar.gz + ${{ steps.get-file-base.outputs.FILE_BASE }}-ubuntu-2204.tar.gz + ${{ steps.get-file-base.outputs.FILE_BASE }}-win_vs2022.zip + if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn` + + - name: Release tag + id: create_release + if: ${{ (inputs.use_environ == 'release') }} + uses: softprops/action-gh-release@v1 + with: + tag_name: "${{ inputs.use_tag }}" + prerelease: false + #body_path: ${{ github.workspace }}-CHANGELOG.txt + files: | + ${{ steps.get-file-base.outputs.FILE_BASE }}.tar.gz + ${{ steps.get-file-base.outputs.FILE_BASE }}.zip + ${{ steps.get-file-base.outputs.FILE_BASE }}-osx12.tar.gz + ${{ steps.get-file-base.outputs.FILE_BASE }}-ubuntu-2204.tar.gz + ${{ steps.get-file-base.outputs.FILE_BASE }}-win_vs2022.zip + if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn` + + - name: List files for the space (Linux) + run: | + ls -l ${{ github.workspace }} + ls ${{ runner.workspace }} + diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..e5e3b2ff --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,100 @@ +name: hdf5 examples release build + +# Controls when the action will run. Triggers the workflow on a manual run +on: + workflow_dispatch: + inputs: + use_tag: + description: 'Release version tag' + type: string + required: false + default: snapshot + +permissions: + contents: read + +# A workflow run is made up of one or more jobs that can run sequentially or +# in parallel. +jobs: + log-the-inputs: + runs-on: ubuntu-latest + outputs: + rel_tag: ${{ steps.get-tag-name.outputs.RELEASE_TAG }} + steps: + - name: Get tag name + id: get-tag-name + env: + TAG: ${{ inputs.use_tag }} + run: echo "RELEASE_TAG=$TAG" >> $GITHUB_OUTPUT + +# tarball.yml will be used for releases when pre-tag actions are implemented +# call-workflow-tarball: +# needs: log-the-inputs +# uses: ./.github/workflows/tarball.yml +# with: +# use_tag: ${{ inputs.use_tag }} +# use_environ: release + + create-files-ctest: + needs: log-the-inputs + runs-on: ubuntu-latest + outputs: + file_base: ${{ steps.set-file-base.outputs.FILE_BASE }} + steps: + - name: Set file base name + id: set-file-base + run: | + FILE_NAME_BASE=$(echo "${{ needs.log-the-inputs.outputs.rel_tag }}") + echo "FILE_BASE=$FILE_NAME_BASE" >> $GITHUB_OUTPUT + shell: bash + + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - name: Get Sources + uses: actions/checkout@v3 + with: + path: hdfsrc + + - name: Zip Folder + run: | + zip -r ${{ steps.set-file-base.outputs.FILE_BASE }}.zip ./hdfsrc + tar -zcvf ${{ steps.set-file-base.outputs.FILE_BASE }}.tar.gz ./hdfsrc + + - name: List files in the repository + run: | + ls -l ${{ github.workspace }} + ls $GITHUB_WORKSPACE + + # Save files created by release script + - name: Save tgz-tarball + uses: actions/upload-artifact@v3 + with: + name: tgz-tarball + path: ${{ steps.set-file-base.outputs.FILE_BASE }}.tar.gz + if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn` + + - name: Save zip-tarball + uses: actions/upload-artifact@v3 + with: + name: zip-tarball + path: ${{ steps.set-file-base.outputs.FILE_BASE }}.zip + if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn` + + call-workflow-ctest: + needs: create-files-ctest + uses: ./.github/workflows/cmake-ctest.yml + with: + file_base: ${{ needs.create-files-ctest.outputs.file_base }} + + call-workflow-release: + #needs: [call-workflow-tarball, call-workflow-ctest] + needs: [log-the-inputs, create-files-ctest, call-workflow-ctest] + permissions: + contents: write # In order to allow tag creation + uses: ./.github/workflows/release-files.yml + with: + file_base: ${{ needs.create-files-ctest.outputs.file_base }} + file_branch: ${{ needs.log-the-inputs.outputs.rel_tag }} + file_sha: ${{ needs.log-the-inputs.outputs.rel_tag }} + use_tag: ${{ needs.log-the-inputs.outputs.rel_tag }} + use_environ: release + diff --git a/.github/workflows/tarball.yml b/.github/workflows/tarball.yml new file mode 100644 index 00000000..f13e817a --- /dev/null +++ b/.github/workflows/tarball.yml @@ -0,0 +1,140 @@ +name: hdf5examples tarball + +# Controls when the action will run. Triggers the workflow on a schedule +on: + workflow_call: + inputs: + use_ignore: + description: 'Ignore has changes check' + type: string + required: false + default: check + use_environ: + description: 'Environment to locate files' + type: string + required: true + default: snapshots + outputs: + has_changes: + description: "Whether there were changes the previous day" + value: ${{ jobs.check_commits.outputs.has_changes }} + file_base: + description: "The common base name of the source tarballs" + value: ${{ jobs.create_tarball.outputs.file_base }} + file_branch: + description: "The branch used for the source tarballs" + value: ${{ jobs.check_commits.outputs.branch_ref }} + file_sha: + description: "The sha used for the source tarballs" + value: ${{ jobs.check_commits.outputs.branch_sha }} + +permissions: + contents: read + +# A workflow run is made up of one or more jobs that can run sequentially or +# in parallel +jobs: + check_commits: + name: Check for recent commits + runs-on: ubuntu-latest + outputs: + has_changes: ${{ steps.check-new-commits.outputs.has-new-commits }} + branch_ref: ${{ steps.get-branch-name.outputs.BRANCH_REF }} + branch_sha: ${{ steps.get-branch-sha.outputs.BRANCH_SHA }} + steps: + - name: Get branch name + id: get-branch-name + env: + GITHUB_REF: ${{ github.ref }} + GITHUB_REF_NAME: ${{ github.ref_name }} + GITHUB_HEAD_REF: ${{ github.head_ref }} + #run: echo "${{ env.GITHUB_REF_NAME }} | grep -P '[0-9]+/merge' &> /dev/null && BRANCH_REF=${{ env.GITHUB_HEAD_REF }} || BRANCH_REF=${{ env.GITHUB_REF_NAME }}" >> $GITHUB_OUTPUT + run: echo "BRANCH_REF=${{ env.GITHUB_HEAD_REF || env.GITHUB_REF_NAME }}" >> $GITHUB_OUTPUT + + - name: Get branch sha + id: get-branch-sha + env: + GITHUB_SHA: ${{ github.sha }} + GITHUB_WF_SHA: ${{ github.workflow_sha }} + run: | + SHORT_SHA=$(echo "${{ env.GITHUB_WF_SHA }}" | cut -c1-7) + echo "BRANCH_SHA=$SHORT_SHA" >> $GITHUB_OUTPUT + + - name: Check for changed source + id: check-new-commits + uses: adriangl/check-new-commits-action@v1 + with: + seconds: 86400 # One day in seconds + branch: '${{ steps.get-branch-name.outputs.branch_ref }}' + if: ${{ inputs.use_environ == 'snapshots' }} + + - run: echo "You have ${{ steps.check-new-commits.outputs.new-commits-number }} new commit(s) in ${{ steps.get-branch-name.outputs.BRANCH_REF }} ✅!" + if: ${{ steps.check-new-commits.outputs.has-new-commits == 'true' }} + + - run: echo "Short commit sha is ${{ steps.get-branch-sha.outputs.BRANCH_SHA }}!" + + create_tarball: + name: Create a source tarball + runs-on: ubuntu-latest + needs: check_commits + if: ${{ ((inputs.use_environ == 'snapshots') && ((needs.check_commits.outputs.has_changes == 'true') || (inputs.use_ignore == 'ignore'))) || (inputs.use_environ == 'release') }} + outputs: + file_base: ${{ steps.set-file-base.outputs.FILE_BASE }} + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - name: Get Sources + uses: actions/checkout@v3 + with: + path: hdfsrc + + - name: Retrieve version + id: version + run: | + cd "$GITHUB_WORKSPACE/hdfsrc" + echo "TAG_VERSION=2.0.4" >> $GITHUB_OUTPUT + + - name: Set file base name + id: set-file-base + run: | + if [[ '${{ inputs.use_environ }}' == 'snapshots' && '${{ needs.check_commits.outputs.has_changes }}' == 'true' ]] + then + FILE_NAME_BASE=$(echo "hdf5-${{ needs.check_commits.outputs.branch_ref }}-${{ needs.check_commits.outputs.branch_sha }}") + else + FILE_NAME_BASE=$(echo "hdf5-${{ steps.version.outputs.TAG_VERSION }}") + fi + echo "FILE_BASE=$FILE_NAME_BASE" >> $GITHUB_OUTPUT + shell: bash + + - name: Create source file (tgz) + id: create-file-tgz + run: | + cd "$GITHUB_WORKSPACE/hdfsrc" + tar -zxvf ${{ github.workspace }}/${{ steps.set-file-base.outputs.FILE_BASE }}.tar.gz + shell: bash + + - name: Create source file (zip) + id: create-file-zip + run: | + cd "$GITHUB_WORKSPACE/hdfsrc" + zip -r ${{ steps.set-file-base.outputs.FILE_BASE }}.zip ./${{ steps.set-file-base.outputs.FILE_BASE }} + shell: bash + + - name: List files in the repository + run: | + ls -l ${{ github.workspace }} + ls $GITHUB_WORKSPACE + + # Save files created by release script + - name: Save tgz-tarball + uses: actions/upload-artifact@v3 + with: + name: tgz-tarball + path: ${{ steps.set-file-base.outputs.FILE_BASE }}.tar.gz + if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn` + + - name: Save zip-tarball + uses: actions/upload-artifact@v3 + with: + name: zip-tarball + path: ${{ steps.set-file-base.outputs.FILE_BASE }}.zip + if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn`