From 7cb6ca928e5b94f59e5e1d30ca399da78e39c39e Mon Sep 17 00:00:00 2001 From: Tim Gilevich Date: Mon, 9 Sep 2024 15:34:35 +0300 Subject: [PATCH] Add HW3 workflow --- .github/workflows/HW3.yml | 138 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100644 .github/workflows/HW3.yml diff --git a/.github/workflows/HW3.yml b/.github/workflows/HW3.yml new file mode 100644 index 0000000..c530b2a --- /dev/null +++ b/.github/workflows/HW3.yml @@ -0,0 +1,138 @@ +name: 'HW3 action' + +on: + workflow_dispatch: + push: + paths: + - 'HW3/**' + - '.github/workflows/HW3.yml' + +permissions: + actions: write + contents: write + +jobs: + build-and-run-job: + env: + target_name: allocator + homework_label: HW3 + cmake_preset: linux-release + cmake_build_preset: linux-build-release + hw_path: ./HW3 + build_folder: build + release_folder: linux-release + version_base: '1.0' + build_tests: ${{ false }} + # Variables to populate in "Initialize variables" step + build_path: + bin_path: + deb_path: + version: + + runs-on: ubuntu-latest + steps: + - name: Initialize variables + run: | + echo "build_path=${{ env.hw_path }}/${{ env.build_folder }}/${{ env.release_folder }}" >> $GITHUB_ENV + echo "bin_path=${{ env.hw_path }}/${{ env.build_folder }}/${{ env.release_folder }}/bin" >> $GITHUB_ENV + echo "deb_path=${{ env.hw_path }}/${{ env.build_folder }}/${{ env.release_folder }}/deb" >> $GITHUB_ENV + echo "version=${{ env.version_base }}.${{ github.run_number }}" >> $GITHUB_ENV + + - name: Checkout + uses: actions/checkout@v4 + + #- name: Update apt-get + # run: sudo apt-get update + + - name: Build package ${{ env.target_name }} + working-directory: ${{env.hw_path}} + run: | + cmake -DBuildTests=${{ env.build_tests }} -DPROJECT_VERSION=${{ env.version }} --preset ${{ env.cmake_preset }} + cmake --build --preset ${{ env.cmake_build_preset }} + + - name: Run tests + if: ${{ env.build_tests }} + working-directory: ${{ env.build_path }} + run: ctest --test-dir . + + - name: Check tests results + if: ${{ env.build_tests && !success()}} + run: | + gh run cancel ${{ github.run_id }} + gh run watch ${{ github.run_id }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Run packet ${{ env.target_name }} + run: '${{ env.bin_path }}/${{ env.target_name }}' + + - name: Build package + working-directory: ${{env.build_path}} + run: cpack -G DEB + + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ env.homework_label }}_${{ github.run_number }} + release_name: ${{ env.homework_label }} release ${{ github.run_number }} + draft: false + prerelease: false + + - name: Upload packet + id: upload-app-asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ${{ env.bin_path }}/${{ env.target_name }} + asset_name: ${{ env.target_name }} + asset_content_type: application/octet-stream + + - name: Upload package + id: upload-package-asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ${{ env.deb_path }}/${{ env.target_name }}-${{ env.version }}-Linux.deb + asset_name: ${{ env.target_name }}-${{ env.version }}-Linux.deb + asset_content_type: application/vnd.debian.binary-package + + - name: Create Doxygen + uses: mattnotmitt/doxygen-action@v1.1.0 + with: + doxyfile-path: ./Doxyfile + working-directory: ${{ env.hw_path }} + + - name: GitHub Pages Deployment + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./doc/html/ + enable_jekyll: false + allow_empty_commit: false + force_orphan: true + publish_branch: gh-pages + + # Build the HTML documentation + - name: Doxygen Action + uses: mattnotmitt/doxygen-action@v1.1.0 + with: + doxyfile-path: ${{ env.hw_path }}/Doxyfile + working-directory: . + + # Deploy the HTML documentation to GitHub Pages + - name: GH Pages Deployment + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ${{ env.hw_path }}/doc/html/ + enable_jekyll: false + allow_empty_commit: false + force_orphan: true + publish_branch: gh-pages