diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml index a7ee5aa5..c6fd64b3 100644 --- a/.github/workflows/code-quality.yml +++ b/.github/workflows/code-quality.yml @@ -2,7 +2,7 @@ name: Code quality and sanity on: push: - branches: '*' + branches: 'main' pull_request: branches: '*' @@ -22,12 +22,12 @@ jobs: - uses: hecrj/setup-rust-action@v1 with: components: clippy - - - name: Verifiying the code quality with Clippy + + - name: Verifiying the code quality with Clippy run: | cd zork++ cargo clippy --all-targets --all-features - + rustfmt: name: Verify code formatting runs-on: ubuntu-latest @@ -36,51 +36,17 @@ jobs: - name: Caching project dependencies id: project-cache uses: Swatinem/rust-cache@v2 - - uses: hecrj/setup-rust-action@v1 + + - uses: hecrj/setup-rust-action@v2 with: components: rustfmt + - name: Checking the format sanity of the project run: | cd zork++ cargo fmt --all -- --check - tests: - name: Run the tests - Clang - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - clang_version: [15, 16, 17] - steps: - - uses: actions/checkout@v3 - - name: Caching project dependencies - id: project-cache - uses: Swatinem/rust-cache@v2 - - name: Install Clang ${{ matrix.clang_version }} - run: | - # Exit on error - set -e - # Download and execute the LLVM installation script for the specified Clang version - echo "-----> Downloading and executing the LLVM installation script for Clang ${{ matrix.clang_version }}" - wget https://apt.llvm.org/llvm.sh - chmod +x llvm.sh - sudo ./llvm.sh ${{ matrix.clang_version }} - - echo "-----> Installing libc++" - sudo apt-get install -y libc++-${{ matrix.clang_version }}-dev libc++abi-${{ matrix.clang_version }}-dev libunwind-${{ matrix.clang_version }} libunwind-${{ matrix.clang_version }}-dev libc6 libzstd1 - - # Update the symbolic link to point to the newly installed Clang version - echo "-----> Updating the symbolic link to point to Clang ${{ matrix.clang_version }}" - sudo rm -f /usr/bin/clang++ - sudo ln -s /usr/bin/clang++-${{ matrix.clang_version }} /usr/bin/clang++ - - - # Display the installation directory and version of the installed Clang - echo "-----> Clang-${{ matrix.clang_version }} was installed on:" - which clang-${{ matrix.clang_version }} - echo "-----> Clang++ was installed on:" - which clang++-${{ matrix.clang_version }} - - name: Running the tests for the project + - name: Run Unit and Doc tests run: | - cd zork++ - RUST_LOG=trace cargo test 2>&1 --all --color=always --no-fail-fast -- --nocapture --show-output --test-threads=1 + cargo test --workspace --lib --color=always --no-fail-fast + cargo test --workspace --doc --color=always --no-fail-fast diff --git a/.github/workflows/tests-clang-linux.yml b/.github/workflows/tests-clang-linux.yml new file mode 100644 index 00000000..b2bf910e --- /dev/null +++ b/.github/workflows/tests-clang-linux.yml @@ -0,0 +1,52 @@ +name: Clang Tests For Linux builds + +on: + push: + branches: 'main' + pull_request: + branches: '*' + +jobs: + tests: + name: Run the tests - Clang + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + clang_version: [15, 16, 17, 18] + steps: + - uses: actions/checkout@v3 + - name: Caching project dependencies + id: project-cache + uses: Swatinem/rust-cache@v2 + + - if: ${{ matrix.clang_version < 18 }} + name: Install Clang ${{ matrix.clang_version }} + run: | + # Exit on error + set -e + # Download and execute the LLVM installation script for the specified Clang version + echo "-----> Downloading and executing the LLVM installation script for Clang ${{ matrix.clang_version }}" + wget https://apt.llvm.org/llvm.sh + chmod +x llvm.sh + sudo ./llvm.sh ${{ matrix.clang_version }} + + echo "-----> Installing libc++" + sudo apt-get install -y libc++-${{ matrix.clang_version }}-dev libc++abi-${{ matrix.clang_version }}-dev libunwind-${{ matrix.clang_version }} libunwind-${{ matrix.clang_version }}-dev libc6 libzstd1 + + # Update the symbolic link to point to the newly installed Clang version + echo "-----> Updating the symbolic link to point to Clang ${{ matrix.clang_version }}" + sudo rm -f /usr/bin/clang++ + sudo ln -s /usr/bin/clang++-${{ matrix.clang_version }} /usr/bin/clang++ + + # Display the installation directory and version of the installed Clang + echo "-----> Clang-${{ matrix.clang_version }} was installed on:" + which clang-${{ matrix.clang_version }} + echo "-----> Clang++ was installed on:" + which clang++-${{ matrix.clang_version }} + + - if: ${{ matrix.clang_version < 18 }} + name: Running the tests for the project + run: | + cd zork++ + RUST_LOG=trace cargo test 2>&1 clang --color=always --no-fail-fast -- --nocapture --show-output --test-threads=1 diff --git a/.github/workflows/tests-gcc.yml b/.github/workflows/tests-gcc.yml new file mode 100644 index 00000000..64d78d47 --- /dev/null +++ b/.github/workflows/tests-gcc.yml @@ -0,0 +1,25 @@ +name: GCC Tests For Linux builds + +on: + push: + branches: 'main' + pull_request: + branches: '*' + +jobs: + tests: + name: Run the tests - GCC + runs-on: ubuntu-latest + strategy: + fail-fast: false + steps: + - uses: actions/checkout@v3 + + - name: Caching project dependencies + id: project-cache + uses: Swatinem/rust-cache@v2 + + - name: Running the tests for the project + run: | + cd zork++ + RUST_LOG=trace cargo test 2>&1 gcc --color=always --no-fail-fast -- --nocapture --show-output --test-threads=1 diff --git a/.github/workflows/tests-msvc.yml b/.github/workflows/tests-msvc.yml new file mode 100644 index 00000000..842109fd --- /dev/null +++ b/.github/workflows/tests-msvc.yml @@ -0,0 +1,30 @@ +name: MSVC Tests For Windows builds + +on: + push: + branches: 'main' + pull_request: + branches: '*' + +jobs: + tests: + name: Run the tests - MSVC + runs-on: windows-latest + strategy: + fail-fast: false + steps: + - uses: actions/checkout@v3 + + - name: Caching project dependencies + id: project-cache + uses: Swatinem/rust-cache@v2 + + - name: Setting up Rust + uses: hecrj/setup-rust-action@v1 + with: + rust-version: stable + + - name: Running the tests for the project + run: | + cd zork++ + cargo test 2>&1 msvc --color=always --no-fail-fast -- --nocapture --show-output --test-threads=1 diff --git a/workflows/code-coverage.yml b/workflows/code-coverage.yml new file mode 100644 index 00000000..7ee940a5 --- /dev/null +++ b/workflows/code-coverage.yml @@ -0,0 +1,64 @@ +name: Code Coverage + +on: + push: + tags: + - 'v[0-9]+.[0-9]+.[0-9]+' + - 'v[0-9]+.[0-9]+.[0-9]+rc[0-9]+' + +env: + CARGO_TERM_COLOR: always + +jobs: + code-coverage: + permissions: + contents: write + env: + CARGO_INCREMENTAL: '0' + RUSTFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' + RUSTDOCFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Use nightly toolchain + run: | + rustup toolchain install nightly + rustup override set nightly + + - name: Caching cargo dependencies + id: project-cache + uses: Swatinem/rust-cache@v2 + + - if: ${{ steps.cache-cargo.outputs.cache-hit != 'true' }} + name: Install grcov + run: cargo install grcov + + - name: Make the USER own the working directory + if: ${{ matrix.os == 'ubuntu-latest' }} + run: sudo chown -R $USER:$USER ${{ github.workspace }} + + - name: Run tests + working-directory: zork++ + run: | + cargo test --all-features --no-fail-fast --target=x86_64-unknown-linux-gnu -- --show-output --test-threads=1 + + - name: Generate code coverage report + working-directory: zork++ + run: | + grcov . -s . --binary-path ./target/debug/ -t html --branch --ignore-not-existing -o ./target/debug/coverage + grcov . -s . --binary-path ./target/debug/ -t cobertura --branch --ignore-not-existing -o ./target/debug/coverage/code_cov.xml + + - name: Publish Test Results + uses: actions/upload-artifact@v3 + with: + name: Unit Test Results + path: | + ./zork++/target/debug/coverage/code_cov.xml + ./zork++/target/debug/coverage/index.html + + - name: Publish coverage report to GitHub Pages + uses: JamesIves/github-pages-deploy-action@v4 + with: + folder: ./zork++/target/debug/coverage + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/workflows/code-quality.yml b/workflows/code-quality.yml new file mode 100644 index 00000000..c6fd64b3 --- /dev/null +++ b/workflows/code-quality.yml @@ -0,0 +1,52 @@ +name: Code quality and sanity + +on: + push: + branches: 'main' + pull_request: + branches: '*' + +jobs: + clippy: + name: Lint with Clippy + runs-on: ubuntu-latest + env: + RUSTFLAGS: -Dwarnings + steps: + - uses: actions/checkout@v3 + + - name: Caching project dependencies + id: project-cache + uses: Swatinem/rust-cache@v2 + + - uses: hecrj/setup-rust-action@v1 + with: + components: clippy + + - name: Verifiying the code quality with Clippy + run: | + cd zork++ + cargo clippy --all-targets --all-features + + rustfmt: + name: Verify code formatting + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Caching project dependencies + id: project-cache + uses: Swatinem/rust-cache@v2 + + - uses: hecrj/setup-rust-action@v2 + with: + components: rustfmt + + - name: Checking the format sanity of the project + run: | + cd zork++ + cargo fmt --all -- --check + + - name: Run Unit and Doc tests + run: | + cargo test --workspace --lib --color=always --no-fail-fast + cargo test --workspace --doc --color=always --no-fail-fast diff --git a/workflows/release.yml b/workflows/release.yml new file mode 100644 index 00000000..056c7f03 --- /dev/null +++ b/workflows/release.yml @@ -0,0 +1,119 @@ +name: Zork++ Release + +on: + push: + tags: + - 'v[0-9]+.[0-9]+.[0-9]+' + - 'v[0-9]+.[0-9]+.[0-9]+rc[0-9]+' + +jobs: + generate-release: + permissions: + contents: write + runs-on: 'ubuntu-latest' + + steps: + - name: Generate release ${{ steps.version.outputs.version }} + uses: actions/create-release@v1 + id: create-release + with: + draft: false + prerelease: false + release_name: ${{ steps.version.outputs.version }} + tag_name: ${{ github.ref }} + env: + GITHUB_TOKEN: ${{ github.token }} + outputs: + upload_url: ${{ steps.create-release.outputs.upload_url }} + + generate-binaries: + needs: 'generate-release' + permissions: + contents: write + strategy: + matrix: + os: ['ubuntu-latest', 'windows-latest'] + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v3 + with: + repository: ${{ github.event.pull_request.head.repo.full_name }} + ref: ${{ github.event.pull_request.head.ref }} + + - name: Caching cargo dependencies + id: project-cache + uses: Swatinem/rust-cache@v2 + + - name: Make Rust environment + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + + - name: Building Zork's exe + working-directory: ./zork++ + run: | + cargo build --release + + - name: Install cargo-deb + run: | + cargo install cargo-deb + + - name: Generate .deb package for Linux + if: ${{ matrix.os == 'ubuntu-latest' }} + working-directory: ./zork++ + run: | + cargo deb --no-build --output ./target/debian/zork.deb + mv ./target/debian/zork.deb ./target/debian/zork++.deb + + - name: Building the installer with Inno Setup + if: ${{ matrix.os == 'windows-latest' }} + run: | + rename ".\zork++\target\release\zork.exe" "zork++.exe" + "%programfiles(x86)%\Inno Setup 6\iscc.exe" ".\release-config\windows-installer-zork.iss" + shell: cmd + + - name: Make Zip for Windows + if: ${{ matrix.os == 'windows-latest' }} + run: | + 7z a windows-installer.zip zork-installer.exe + + - name: Generate compressed tar archive for Linux + if: ${{ matrix.os == 'ubuntu-latest' }} + working-directory: ./zork++ + run: | + mv ./target/release/zork ./target/release/zork++ + tar -czvf zork++.tar.gz ./target/release/zork++ ../LICENSE + + - name: Upload Windows artifact + if: ${{ matrix.os == 'windows-latest' }} + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ github.token }} + with: + upload_url: ${{ needs.generate-release.outputs.upload_url }} + asset_path: windows-installer.zip + asset_name: windows-installer.zip + asset_content_type: application/zip + + - name: Upload Linux tar archive + if: ${{ matrix.os == 'ubuntu-latest' }} + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ github.token }} + with: + upload_url: ${{ needs.generate-release.outputs.upload_url }} + asset_path: ./zork++/zork++.tar.gz + asset_name: ./zork++/zork++.tar.gz + asset_content_type: application/tar+gzip + + - name: Upload Linux .deb package + if: ${{ matrix.os == 'ubuntu-latest' }} + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ github.token }} + with: + upload_url: ${{ needs.generate-release.outputs.upload_url }} + asset_path: zork++/target/debian/zork++.deb + asset_name: zork++.deb + asset_content_type: application/vnd.debian.binary-package diff --git a/workflows/tests-clang-linux.yml b/workflows/tests-clang-linux.yml new file mode 100644 index 00000000..b2bf910e --- /dev/null +++ b/workflows/tests-clang-linux.yml @@ -0,0 +1,52 @@ +name: Clang Tests For Linux builds + +on: + push: + branches: 'main' + pull_request: + branches: '*' + +jobs: + tests: + name: Run the tests - Clang + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + clang_version: [15, 16, 17, 18] + steps: + - uses: actions/checkout@v3 + - name: Caching project dependencies + id: project-cache + uses: Swatinem/rust-cache@v2 + + - if: ${{ matrix.clang_version < 18 }} + name: Install Clang ${{ matrix.clang_version }} + run: | + # Exit on error + set -e + # Download and execute the LLVM installation script for the specified Clang version + echo "-----> Downloading and executing the LLVM installation script for Clang ${{ matrix.clang_version }}" + wget https://apt.llvm.org/llvm.sh + chmod +x llvm.sh + sudo ./llvm.sh ${{ matrix.clang_version }} + + echo "-----> Installing libc++" + sudo apt-get install -y libc++-${{ matrix.clang_version }}-dev libc++abi-${{ matrix.clang_version }}-dev libunwind-${{ matrix.clang_version }} libunwind-${{ matrix.clang_version }}-dev libc6 libzstd1 + + # Update the symbolic link to point to the newly installed Clang version + echo "-----> Updating the symbolic link to point to Clang ${{ matrix.clang_version }}" + sudo rm -f /usr/bin/clang++ + sudo ln -s /usr/bin/clang++-${{ matrix.clang_version }} /usr/bin/clang++ + + # Display the installation directory and version of the installed Clang + echo "-----> Clang-${{ matrix.clang_version }} was installed on:" + which clang-${{ matrix.clang_version }} + echo "-----> Clang++ was installed on:" + which clang++-${{ matrix.clang_version }} + + - if: ${{ matrix.clang_version < 18 }} + name: Running the tests for the project + run: | + cd zork++ + RUST_LOG=trace cargo test 2>&1 clang --color=always --no-fail-fast -- --nocapture --show-output --test-threads=1 diff --git a/workflows/tests-gcc.yml b/workflows/tests-gcc.yml new file mode 100644 index 00000000..64d78d47 --- /dev/null +++ b/workflows/tests-gcc.yml @@ -0,0 +1,25 @@ +name: GCC Tests For Linux builds + +on: + push: + branches: 'main' + pull_request: + branches: '*' + +jobs: + tests: + name: Run the tests - GCC + runs-on: ubuntu-latest + strategy: + fail-fast: false + steps: + - uses: actions/checkout@v3 + + - name: Caching project dependencies + id: project-cache + uses: Swatinem/rust-cache@v2 + + - name: Running the tests for the project + run: | + cd zork++ + RUST_LOG=trace cargo test 2>&1 gcc --color=always --no-fail-fast -- --nocapture --show-output --test-threads=1 diff --git a/workflows/tests-msvc.yml b/workflows/tests-msvc.yml new file mode 100644 index 00000000..842109fd --- /dev/null +++ b/workflows/tests-msvc.yml @@ -0,0 +1,30 @@ +name: MSVC Tests For Windows builds + +on: + push: + branches: 'main' + pull_request: + branches: '*' + +jobs: + tests: + name: Run the tests - MSVC + runs-on: windows-latest + strategy: + fail-fast: false + steps: + - uses: actions/checkout@v3 + + - name: Caching project dependencies + id: project-cache + uses: Swatinem/rust-cache@v2 + + - name: Setting up Rust + uses: hecrj/setup-rust-action@v1 + with: + rust-version: stable + + - name: Running the tests for the project + run: | + cd zork++ + cargo test 2>&1 msvc --color=always --no-fail-fast -- --nocapture --show-output --test-threads=1