From 98abff1c163c7da1fca031debe711480831a9666 Mon Sep 17 00:00:00 2001 From: Xavier Mitault <xavier.mitault@epitech.eu> Date: Wed, 29 Nov 2023 16:56:59 +0000 Subject: [PATCH 01/23] Add some CI/CD tools MINOR --- .github/workflows/compil.yml | 80 ++++++++++++++++ .github/workflows/documentation.yml | 65 +++++++++++++ .github/workflows/mirror.yml | 24 +++++ .github/workflows/norm.yml | 38 ++++++++ .github/workflows/release.sh | 46 ++++++++++ .github/workflows/release.yml | 137 ++++++++++++++++++++++++++++ scripts/InstallDepsLinux.bash | 15 +++ scripts/InstallDepsMacos.zsh | 3 + scripts/InstallDepsWindows.ps1 | 7 ++ 9 files changed, 415 insertions(+) create mode 100644 .github/workflows/compil.yml create mode 100644 .github/workflows/documentation.yml create mode 100644 .github/workflows/mirror.yml create mode 100644 .github/workflows/norm.yml create mode 100755 .github/workflows/release.sh create mode 100644 .github/workflows/release.yml create mode 100755 scripts/InstallDepsLinux.bash create mode 100755 scripts/InstallDepsMacos.zsh create mode 100644 scripts/InstallDepsWindows.ps1 diff --git a/.github/workflows/compil.yml b/.github/workflows/compil.yml new file mode 100644 index 0000000..5425825 --- /dev/null +++ b/.github/workflows/compil.yml @@ -0,0 +1,80 @@ +name: Compil + +on: [push] + +jobs: + compil-check-job-run: + runs-on: ubuntu-latest + + outputs: + workflows: ${{ steps.filter.outputs.workflows }} + src: ${{ steps.filter.outputs.src }} + make: ${{ steps.filter.outputs.make }} + combined: ${{ steps.filter.outputs.workflows == 'true' || steps.filter.outputs.src == 'true' || steps.filter.outputs.make == 'true' }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Check modified files need re run + id: filter + uses: dorny/paths-filter@v2 + with: + filters: | + workflows: + - '.github/workflows/**' + src: + - '*.hs' + cmake: + - 'Makefile' + + windows-compil: + runs-on: windows-latest + needs: [compil-check-job-run] + if: needs.compil-check-job-run.outputs.combined || github.event_name == 'pull_request' + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install winget + uses: Cyberboss/install-winget@v1 + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Install dependencies + run: ./scripts/install-deps-windows.ps1 + + - name: Compil + run: ./scripts/compil.ps1 --no-tidy + + linux-compil: + runs-on: ubuntu-latest + needs: [compil-check-job-run] + if: needs.compil-check-job-run.outputs.combined || github.event_name == 'pull_request' + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install dependencies + run: sudo ./scripts/install-deps-linux.sh + + - name: Compil + run: ./scripts/compil.sh --no-tidy --no-parallel + + macos-compil: + runs-on: macos-latest + needs: [compil-check-job-run] + if: needs.compil-check-job-run.outputs.combined || github.event_name == 'pull_request' + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install dependencies + run: ./scripts/install-deps-macos.sh + + - name: Compil + run: ./scripts/compil.sh --no-tidy + diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml new file mode 100644 index 0000000..bc6f53f --- /dev/null +++ b/.github/workflows/documentation.yml @@ -0,0 +1,65 @@ +name: Documentation +on: [push] + +jobs: + deploy: + runs-on: ubuntu-latest + permissions: + contents: write # To push a branch + pages: write # To push to a GitHub Pages site + id-token: write # To update the deployment status + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Check modified files need re run + id: filter + uses: dorny/paths-filter@v2 + with: + filters: | + docs: + - 'docs/**' + docs2: + - 'book.toml' + workflow: + - '.github/workflows/documentation.yml' + + - name: Install latest mdbook + if: steps.filter.outputs.docs == 'true' || steps.filter.outputs.docs2 == 'true' || steps.filter.outputs.workflow == 'true' || github.ref == 'refs/heads/main' + run: | + tag=$(curl 'https://api.github.com/repos/rust-lang/mdbook/releases/latest' | jq -r '.tag_name') + url="https://github.com/rust-lang/mdbook/releases/download/${tag}/mdbook-${tag}-x86_64-unknown-linux-gnu.tar.gz" + mkdir mdbook + curl -sSL $url | tar -xz --directory=./mdbook + echo `pwd`/mdbook >> $GITHUB_PATH + + - name: Install emojify + if: steps.filter.outputs.docs == 'true' || steps.filter.outputs.docs2 == 'true' || steps.filter.outputs.workflow == 'true' || github.ref == 'refs/heads/main' + run: | + wget --no-verbose https://github.com/shonfeder/emojitsu/releases/download/0.1.1/gh-actions-emojitsu + chmod +x gh-actions-emojitsu + # Emojify the markdown + find . -type f -name "*.md" -exec ./gh-actions-emojitsu emojify -i {} \; + + - name: Build Book + if: steps.filter.outputs.docs == 'true' || steps.filter.outputs.docs2 == 'true' || steps.filter.outputs.workflow == 'true' || github.ref == 'refs/heads/main' + run: mdbook build + + - name: Setup Pages + if: github.ref == 'refs/heads/main' + uses: actions/configure-pages@v3 + + - name: Upload artifact + if: steps.filter.outputs.docs == 'true' || steps.filter.outputs.docs2 == 'true' || steps.filter.outputs.workflow == 'true' || github.ref == 'refs/heads/main' + uses: actions/upload-pages-artifact@v2 + with: + # Upload entire repository + path: 'book' + + - name: Deploy to GitHub Pages + if: github.ref == 'refs/heads/main' + id: deployment + uses: actions/deploy-pages@v2 diff --git a/.github/workflows/mirror.yml b/.github/workflows/mirror.yml new file mode 100644 index 0000000..8ac4788 --- /dev/null +++ b/.github/workflows/mirror.yml @@ -0,0 +1,24 @@ +name: Mirror + +on: [push] + +env: + MIRROR_URL: git@github.com:EpitechPromo2026/B-FUN-500-TLS-5-2-glados-xavier.mitault.git + +jobs: + publish: + runs-on: ubuntu-latest + if: ${{ github.event_name == 'push' }} + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: pixta-dev/repository-mirroring-action@v1 + if: github.repository != 'EpitechPromo2026/B-FUN-500-TLS-5-2-glados-xavier.mitault' + with: + target_repo_url: + ${{ env.MIRROR_URL }} + ssh_private_key: + ${{ secrets.SSH_KEY }} diff --git a/.github/workflows/norm.yml b/.github/workflows/norm.yml new file mode 100644 index 0000000..33eb36d --- /dev/null +++ b/.github/workflows/norm.yml @@ -0,0 +1,38 @@ +name: Norm + +on: [pull_request] + +jobs: + + format: + runs-on: ubuntu-latest + image: ghcr.io/epitech/coding-style-checker:latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Format + run: code-style-haskell.sh . . + + - name: Is Empty + id: isEmpty + run: | + if [ "$(cat coding-style-reports.log)" == "" ]; then + echo "isEmpty=true" >> $GITHUB_OUTPUT + else + echo "isEmpty=false" >> $GITHUB_OUTPUT + fi + + - name: Send coding style message Ok + uses: mshick/add-pr-comment@v2 + if: ${{ steps.isEmpty.outputs.isEmpty == "true" }} + with: + message: "No coding style issue" + + - name: Send coding style message KO + uses: mshick/add-pr-comment@v2 + if: ${{ steps.isEmpty.outputs.isEmpty == "false" }} + with: + message-path: | + coding-style-reports.log diff --git a/.github/workflows/release.sh b/.github/workflows/release.sh new file mode 100755 index 0000000..dc25df6 --- /dev/null +++ b/.github/workflows/release.sh @@ -0,0 +1,46 @@ +#!/bin/bash +# Release script run in Github CI + +BRANCH="$1" + +LAST_TAG=$(git tag | sort -t '.' --numeric-sort -k1,1 -k2,2 -k3,3 | tail -n 1) +LAST_TAG_MAJOR=$(echo "$LAST_TAG" | cut -d'.' -f1) +LAST_TAG_MINOR=$(echo "$LAST_TAG" | cut -d'.' -f2) +LAST_TAG_PATCH=$(echo "$LAST_TAG" | cut -d'.' -f3) + +git show --compact-summary "$LAST_TAG..HEAD" > CHANGELOG + +TAG_MAJOR="" +TAG_MINOR="" +TAG_PATCH="" + +WARNINGS="" + +if grep -q "^ MAJOR" CHANGELOG; then + TAG_MAJOR=$((LAST_TAG_MAJOR + 1)) + TAG_MINOR="0" + TAG_PATCH="0" +elif grep -q "^ MINOR" CHANGELOG; then + TAG_MAJOR=$((LAST_TAG_MAJOR + 0)) + TAG_MINOR=$((LAST_TAG_MINOR + 1)) + TAG_PATCH="0" +elif grep -q "^ PATCH" CHANGELOG; then + TAG_MAJOR=$((LAST_TAG_MAJOR + 0)) + TAG_MINOR=$((LAST_TAG_MINOR + 0)) + TAG_PATCH=$((LAST_TAG_PATCH + 1)) +else + WARNINGS="$WARNINGS ; This release is created with default bump version because no commits was ok" + TAG_MAJOR=$((LAST_TAG_MAJOR + 0)) + TAG_MINOR=$((LAST_TAG_MINOR + 0)) + TAG_PATCH=$((LAST_TAG_PATCH + 1)) +fi + +TAG="$TAG_MAJOR.$TAG_MINOR.$TAG_PATCH" + +gh release create "$TAG" \ + --title "v$TAG" \ + --generate-notes \ + --target "$BRANCH" + +echo "release_tag=$TAG" >> $GITHUB_OUTPUT +echo "$WARNINGS" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..bcae913 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,137 @@ +name: Release + +on: + push: + branches: [main, dev] + +env: + BRANCH: "main" + +jobs: + release-create: + permissions: write-all + runs-on: ubuntu-latest + + outputs: + release: ${{ steps.release.outputs.release_tag }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - id: release + name: Create Release + if: github.repository != 'EpitechPromo2026/B-FUN-500-TLS-5-2-glados-xavier.mitault' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + if [[ "${{ github.ref }}" == 'refs/heads/main' ]]; then + export GITHUB_OUTPUT=$GITHUB_OUTPUT + bash ./.github/workflows/release.sh "${{ env.BRANCH }}" + else + echo "release_tag=0.0.0" >> $GITHUB_OUTPUT + fi + + release-windows: + runs-on: ubuntu-latest + needs: [release-create] + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install Haskell + uses: haskell-actions/setup@v2 + with: + enable-stack: true + stack-version: 'latest' + + - name: Install dependencies + run: .\scripts\InstallDepsWindows.ps1 + + - name: Build + run: make + + - name: Upload To Release + if: github.ref == 'refs/heads/main' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh release upload ${{ needs.release-create.outputs.release }} ".\koaky.exe#koaky-windows.exe" + + - name: Upload To Artifact + if: github.ref != 'refs/heads/main' + uses: actions/upload-artifact@v3 + with: + name: koaky.exe + path: .\koaky.exe + + release-linux: + runs-on: ubuntu-latest + needs: [release-create] + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install Haskell + uses: haskell-actions/setup@v2 + with: + enable-stack: true + stack-version: 'latest' + + - name: Install dependencies + run: ./scripts/InstallDepsLinux.bash + + - name: Build + run: make + + - name: Upload To Release + if: github.ref == 'refs/heads/main' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh release upload ${{ needs.release-create.outputs.release }} "./koaky#koaky-linux" + + - name: Upload To Artifact + if: github.ref != 'refs/heads/main' + uses: actions/upload-artifact@v3 + with: + name: koaky-linux + path: ./koaky + + release-macos: + runs-on: macos-latest + needs: [release-create] + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install Haskell + uses: haskell-actions/setup@v2 + with: + enable-stack: true + stack-version: 'latest' + + - name: Install dependencies + run: ./scripts/InstallDepsMacos.zsh + + - name: Build + run: make + + - name: Upload To Release + if: github.ref == 'refs/heads/main' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh release upload ${{ needs.release-create.outputs.release }} "./koaky#koaky-macos" + + - name: Upload To Artifact + if: github.ref != 'refs/heads/main' + uses: actions/upload-artifact@v3 + with: + name: koaky-macos + path: ./koaky diff --git a/scripts/InstallDepsLinux.bash b/scripts/InstallDepsLinux.bash new file mode 100755 index 0000000..eaccb47 --- /dev/null +++ b/scripts/InstallDepsLinux.bash @@ -0,0 +1,15 @@ +#!/bin/bash + +if command -v apt-get 2>/dev/null; then + apt-get update + apt-get install -y make +elif command -v pacman 2>/dev/null; then + pacman -Sy make +elif command -v dnf 2>/dev/null; then + dnf update + dnf install -y make +else + echo "Unsupported package manager" + echo "Please install 'make'" + exit 12 +fi diff --git a/scripts/InstallDepsMacos.zsh b/scripts/InstallDepsMacos.zsh new file mode 100755 index 0000000..d639cf0 --- /dev/null +++ b/scripts/InstallDepsMacos.zsh @@ -0,0 +1,3 @@ +#!/bin/zsh + +brew install make diff --git a/scripts/InstallDepsWindows.ps1 b/scripts/InstallDepsWindows.ps1 new file mode 100644 index 0000000..7662c62 --- /dev/null +++ b/scripts/InstallDepsWindows.ps1 @@ -0,0 +1,7 @@ +if (!(Test-Path "make.exe") -or !(Test-Path "libssp-0.dll")) { + Invoke-WebRequest -OutFile make.zip -Uri "https://github.com/maweil/MakeForWindows/releases/download/v4.4.1/make-bin-win64.zip" + Expand-Archive -Force make.zip . + Copy-Item "make-4.4.1\dist\make.exe" "make.exe" + Copy-Item "make-4.4.1\dist\libssp-0.dll" "libssp-0.dll" + Remove-Item -Recurse -Force make +} From 23bae450a171dbb953794fa265a4401f29b8957a Mon Sep 17 00:00:00 2001 From: Xavier Mitault <xavier.mitault@epitech.eu> Date: Wed, 29 Nov 2023 17:15:29 +0000 Subject: [PATCH 02/23] Fix CICD compil PATCH --- .github/workflows/compil.yml | 36 +++++++++++++++++++++++------------ .github/workflows/release.yml | 8 ++++---- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/.github/workflows/compil.yml b/.github/workflows/compil.yml index 5425825..e2a46a2 100644 --- a/.github/workflows/compil.yml +++ b/.github/workflows/compil.yml @@ -31,19 +31,20 @@ jobs: windows-compil: runs-on: windows-latest needs: [compil-check-job-run] - if: needs.compil-check-job-run.outputs.combined || github.event_name == 'pull_request' + if: needs.compil-check-job-run.outputs.combined steps: - name: Checkout uses: actions/checkout@v4 - - name: Install winget - uses: Cyberboss/install-winget@v1 + - name: Install Haskell + uses: haskell-actions/setup@v2 with: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + enable-stack: true + stack-version: 'latest' - name: Install dependencies - run: ./scripts/install-deps-windows.ps1 + run: ./scripts/InstallDepsWindows.ps1 - name: Compil run: ./scripts/compil.ps1 --no-tidy @@ -51,30 +52,41 @@ jobs: linux-compil: runs-on: ubuntu-latest needs: [compil-check-job-run] - if: needs.compil-check-job-run.outputs.combined || github.event_name == 'pull_request' + if: needs.compil-check-job-run.outputs.combined steps: - name: Checkout uses: actions/checkout@v4 + - name: Install Haskell + uses: haskell-actions/setup@v2 + with: + enable-stack: true + stack-version: 'latest' + - name: Install dependencies - run: sudo ./scripts/install-deps-linux.sh + run: sudo ./scripts/InstallDepsLinux.bash - name: Compil - run: ./scripts/compil.sh --no-tidy --no-parallel + run: make macos-compil: runs-on: macos-latest needs: [compil-check-job-run] - if: needs.compil-check-job-run.outputs.combined || github.event_name == 'pull_request' + if: needs.compil-check-job-run.outputs.combined steps: - name: Checkout uses: actions/checkout@v4 + - name: Install Haskell + uses: haskell-actions/setup@v2 + with: + enable-stack: true + stack-version: 'latest' + - name: Install dependencies - run: ./scripts/install-deps-macos.sh + run: ./scripts/InstallDepsMacOS.zsh - name: Compil - run: ./scripts/compil.sh --no-tidy - + run: make diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bcae913..b0f67f0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -49,7 +49,7 @@ jobs: stack-version: 'latest' - name: Install dependencies - run: .\scripts\InstallDepsWindows.ps1 + run: ./scripts/InstallDepsWindows.ps1 - name: Build run: make @@ -59,14 +59,14 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - gh release upload ${{ needs.release-create.outputs.release }} ".\koaky.exe#koaky-windows.exe" + gh release upload ${{ needs.release-create.outputs.release }} "./koaky.exe#koaky-windows.exe" - name: Upload To Artifact if: github.ref != 'refs/heads/main' uses: actions/upload-artifact@v3 with: name: koaky.exe - path: .\koaky.exe + path: ./koaky.exe release-linux: runs-on: ubuntu-latest @@ -83,7 +83,7 @@ jobs: stack-version: 'latest' - name: Install dependencies - run: ./scripts/InstallDepsLinux.bash + run: sudo ./scripts/InstallDepsLinux.bash - name: Build run: make From ef1365ea444a921e3d829f20d5148fba6e5302d2 Mon Sep 17 00:00:00 2001 From: Xavier Mitault <xavier.mitault@epitech.eu> Date: Wed, 29 Nov 2023 17:35:27 +0000 Subject: [PATCH 03/23] Fix CICD Windows + release push double file PATCH --- .github/workflows/release.yml | 14 ++++++++++---- scripts/InstallDepsWindows.ps1 | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b0f67f0..1296710 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -88,19 +88,22 @@ jobs: - name: Build run: make + - name: Rename + run: mv koaky koaky-linux + - name: Upload To Release if: github.ref == 'refs/heads/main' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - gh release upload ${{ needs.release-create.outputs.release }} "./koaky#koaky-linux" + gh release upload ${{ needs.release-create.outputs.release }} "./koaky-linux" - name: Upload To Artifact if: github.ref != 'refs/heads/main' uses: actions/upload-artifact@v3 with: name: koaky-linux - path: ./koaky + path: ./koaky-linux release-macos: runs-on: macos-latest @@ -122,16 +125,19 @@ jobs: - name: Build run: make + - name: Rename + run: mv koaky koaky-macos + - name: Upload To Release if: github.ref == 'refs/heads/main' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - gh release upload ${{ needs.release-create.outputs.release }} "./koaky#koaky-macos" + gh release upload ${{ needs.release-create.outputs.release }} "./koaky-macos" - name: Upload To Artifact if: github.ref != 'refs/heads/main' uses: actions/upload-artifact@v3 with: name: koaky-macos - path: ./koaky + path: ./koaky-macos diff --git a/scripts/InstallDepsWindows.ps1 b/scripts/InstallDepsWindows.ps1 index 7662c62..85207f0 100644 --- a/scripts/InstallDepsWindows.ps1 +++ b/scripts/InstallDepsWindows.ps1 @@ -3,5 +3,5 @@ if (!(Test-Path "make.exe") -or !(Test-Path "libssp-0.dll")) { Expand-Archive -Force make.zip . Copy-Item "make-4.4.1\dist\make.exe" "make.exe" Copy-Item "make-4.4.1\dist\libssp-0.dll" "libssp-0.dll" - Remove-Item -Recurse -Force make + Remove-Item -Recurse -Force "make-4.4.1" } From 91432ba677b2ba6915b5767ac449f093bdaa2c22 Mon Sep 17 00:00:00 2001 From: Xavier Mitault <xavier.mitault@epitech.eu> Date: Wed, 29 Nov 2023 17:38:47 +0000 Subject: [PATCH 04/23] Fix CICD Windows PATCH --- .github/workflows/compil.yml | 2 +- .github/workflows/release.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/compil.yml b/.github/workflows/compil.yml index e2a46a2..d3a309d 100644 --- a/.github/workflows/compil.yml +++ b/.github/workflows/compil.yml @@ -47,7 +47,7 @@ jobs: run: ./scripts/InstallDepsWindows.ps1 - name: Compil - run: ./scripts/compil.ps1 --no-tidy + run: make linux-compil: runs-on: ubuntu-latest diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1296710..f262282 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -35,7 +35,7 @@ jobs: fi release-windows: - runs-on: ubuntu-latest + runs-on: windows-latest needs: [release-create] steps: From d4514b29e48e72a03705ba2d41c8f449c0cb2be4 Mon Sep 17 00:00:00 2001 From: Xavier Mitault <xavier.mitault@epitech.eu> Date: Wed, 29 Nov 2023 17:48:31 +0000 Subject: [PATCH 05/23] Add documentation MINOR --- book.toml | 23 +++++++++++++++++++++++ docs/README.md | 4 ++++ docs/SUMMARY.md | 3 +++ 3 files changed, 30 insertions(+) create mode 100644 book.toml create mode 100644 docs/README.md create mode 100644 docs/SUMMARY.md diff --git a/book.toml b/book.toml new file mode 100644 index 0000000..c40f347 --- /dev/null +++ b/book.toml @@ -0,0 +1,23 @@ +[book] +title = "Koaky (Yet Another Programming Language)" +authors = ["@Saverio976", "@TTENSHII", "@guillaumeAbel"] +description = "Documentation of Koaky" +src = "docs" + +[build] +build-dir = "book" +create-missing = false +use-default-preprocessors = true + +[output.html] +git-repository-url = "https://github.com/X-R-G-B/koak" +edit-url-template = "https://github.com/X-R-G-B/koak/edit/main/{path}" + +[output.html.search] +enable = true +use-boolean-and = true +limit-results = 15 + +[output.html.print] +enable = true +page-break = true diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000..fd86e18 --- /dev/null +++ b/docs/README.md @@ -0,0 +1,4 @@ +# Koaky + +This is a new amazing programming language +made in Haskell. diff --git a/docs/SUMMARY.md b/docs/SUMMARY.md new file mode 100644 index 0000000..ef6ac93 --- /dev/null +++ b/docs/SUMMARY.md @@ -0,0 +1,3 @@ +# Summary + +[README](README.md) From b5c7257387b533b3a3e4d95a05946d5eb2736b90 Mon Sep 17 00:00:00 2001 From: Xavier Mitault <xavier.mitault@epitech.eu> Date: Wed, 29 Nov 2023 18:51:20 +0000 Subject: [PATCH 06/23] Fix makefile for Windows PATCH --- Makefile | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 2ab2689..783ef2d 100644 --- a/Makefile +++ b/Makefile @@ -8,20 +8,33 @@ TARGET = koaky MARVIN_TARGET = glados +ifeq ($(OS),Windows_NT) + CP = Copy-Item + RM = Remove-Item -Force -Recurse + BIN_STACK = $(TARGET)-exe.exe + BIN_TARGET = $(TARGET).exe +else + CP = cp + RM = rm -rf + BIN_STACK = $(TARGET)-exe + BIN_TARGET = $(TARGET) +endif + all: $(TARGET) $(TARGET): stack build - cp "$(shell stack path --local-install-root)/bin/$(TARGET)-exe" "$(TARGET)" - cp "$(TARGET)" "$(MARVIN_TARGET)" + echo $(shell stack path --local-install-root) + $(CP) "$(shell stack path --local-install-root)/bin/$(BIN_STACK)" "$(BIN_TARGET)" + $(CP) "$(BIN_TARGET)" "$(MARVIN_TARGET)" clean: stack purge fclean: clean - $(RM) "$(TARGET)" + $(RM) "$(BIN_TARGET)" $(RM) "$(MARVIN_TARGET)" -re: fclean "$(TARGET)" +re: fclean $(TARGET) .PHONY: $(TARGET) fclean re clean all From 817c52d4fa1053f92c8747d59219fd01982de01c Mon Sep 17 00:00:00 2001 From: Xavier Mitault <xavier.mitault@epitech.eu> Date: Wed, 29 Nov 2023 19:27:21 +0000 Subject: [PATCH 07/23] Fix Windows makefile copy PATCH --- .github/workflows/compil.yml | 6 +++--- .github/workflows/documentation.yml | 2 +- .github/workflows/mirror.yml | 2 +- .github/workflows/norm.yml | 2 +- .gitignore | 3 +++ Makefile | 8 ++++++-- 6 files changed, 15 insertions(+), 8 deletions(-) diff --git a/.github/workflows/compil.yml b/.github/workflows/compil.yml index d3a309d..06faaca 100644 --- a/.github/workflows/compil.yml +++ b/.github/workflows/compil.yml @@ -28,7 +28,7 @@ jobs: cmake: - 'Makefile' - windows-compil: + compil-windows: runs-on: windows-latest needs: [compil-check-job-run] if: needs.compil-check-job-run.outputs.combined @@ -49,7 +49,7 @@ jobs: - name: Compil run: make - linux-compil: + compil-linux: runs-on: ubuntu-latest needs: [compil-check-job-run] if: needs.compil-check-job-run.outputs.combined @@ -70,7 +70,7 @@ jobs: - name: Compil run: make - macos-compil: + compil-macos: runs-on: macos-latest needs: [compil-check-job-run] if: needs.compil-check-job-run.outputs.combined diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index bc6f53f..017b93a 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -2,7 +2,7 @@ name: Documentation on: [push] jobs: - deploy: + documentation: runs-on: ubuntu-latest permissions: contents: write # To push a branch diff --git a/.github/workflows/mirror.yml b/.github/workflows/mirror.yml index 8ac4788..983b349 100644 --- a/.github/workflows/mirror.yml +++ b/.github/workflows/mirror.yml @@ -6,7 +6,7 @@ env: MIRROR_URL: git@github.com:EpitechPromo2026/B-FUN-500-TLS-5-2-glados-xavier.mitault.git jobs: - publish: + mirror: runs-on: ubuntu-latest if: ${{ github.event_name == 'push' }} diff --git a/.github/workflows/norm.yml b/.github/workflows/norm.yml index 33eb36d..d35a138 100644 --- a/.github/workflows/norm.yml +++ b/.github/workflows/norm.yml @@ -4,7 +4,7 @@ on: [pull_request] jobs: - format: + norm: runs-on: ubuntu-latest image: ghcr.io/epitech/coding-style-checker:latest diff --git a/.gitignore b/.gitignore index 7d017d8..170268a 100644 --- a/.gitignore +++ b/.gitignore @@ -170,3 +170,6 @@ tags /glados *.log + +/make.exe +/libssp-0.dll diff --git a/Makefile b/Makefile index 783ef2d..1461042 100644 --- a/Makefile +++ b/Makefile @@ -24,14 +24,18 @@ all: $(TARGET) $(TARGET): stack build - echo $(shell stack path --local-install-root) +ifeq ($(OS),Windows_NT) + $(CP) "(stack path --local-install-root)/bin/$(BIN_STACK)" "$(BIN_TARGET)" +else $(CP) "$(shell stack path --local-install-root)/bin/$(BIN_STACK)" "$(BIN_TARGET)" +endif $(CP) "$(BIN_TARGET)" "$(MARVIN_TARGET)" clean: - stack purge + stack clean fclean: clean + stack purge $(RM) "$(BIN_TARGET)" $(RM) "$(MARVIN_TARGET)" From 41afc130c0053e0a41f2e3fb3d7a970b65e860c5 Mon Sep 17 00:00:00 2001 From: Xavier Mitault <xavier.mitault@epitech.eu> Date: Wed, 29 Nov 2023 19:35:29 +0000 Subject: [PATCH 08/23] Try to use command.exe on windows PATCH --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 1461042..76424ca 100644 --- a/Makefile +++ b/Makefile @@ -13,6 +13,7 @@ ifeq ($(OS),Windows_NT) RM = Remove-Item -Force -Recurse BIN_STACK = $(TARGET)-exe.exe BIN_TARGET = $(TARGET).exe + SHELL = command.exe else CP = cp RM = rm -rf From 1e2972340aa3186217fcb9de3c43f99ffcd5f8e4 Mon Sep 17 00:00:00 2001 From: Xavier Mitault <xavier.mitault@epitech.eu> Date: Wed, 29 Nov 2023 20:03:06 +0000 Subject: [PATCH 09/23] Add script distinct for linux and windows PATCH --- Makefile | 13 +++++-------- scripts/Build.ps1 | 8 ++++++++ scripts/Build.sh | 8 ++++++++ 3 files changed, 21 insertions(+), 8 deletions(-) create mode 100644 scripts/Build.ps1 create mode 100755 scripts/Build.sh diff --git a/Makefile b/Makefile index 76424ca..dc2483e 100644 --- a/Makefile +++ b/Makefile @@ -8,15 +8,13 @@ TARGET = koaky MARVIN_TARGET = glados +CP = cp +RM = rm -rf + ifeq ($(OS),Windows_NT) - CP = Copy-Item - RM = Remove-Item -Force -Recurse BIN_STACK = $(TARGET)-exe.exe BIN_TARGET = $(TARGET).exe - SHELL = command.exe else - CP = cp - RM = rm -rf BIN_STACK = $(TARGET)-exe BIN_TARGET = $(TARGET) endif @@ -24,11 +22,10 @@ endif all: $(TARGET) $(TARGET): - stack build ifeq ($(OS),Windows_NT) - $(CP) "(stack path --local-install-root)/bin/$(BIN_STACK)" "$(BIN_TARGET)" + ./scripts/Build.ps1 else - $(CP) "$(shell stack path --local-install-root)/bin/$(BIN_STACK)" "$(BIN_TARGET)" + ./scripts/Build.sh endif $(CP) "$(BIN_TARGET)" "$(MARVIN_TARGET)" diff --git a/scripts/Build.ps1 b/scripts/Build.ps1 new file mode 100644 index 0000000..b7fe730 --- /dev/null +++ b/scripts/Build.ps1 @@ -0,0 +1,8 @@ +$binStack = $args[0] +$binTarget = $args[1] + +stack build + +$pathLocalRoot = stack path --local-install-root + +Copy-Item "$pathLocalRoot/bin/$binStack" "$binTarget" diff --git a/scripts/Build.sh b/scripts/Build.sh new file mode 100755 index 0000000..cebe263 --- /dev/null +++ b/scripts/Build.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +BIN_STACK="$1" +BIN_TARGET="$2" + +stack build + +cp "$(stack path --local-install-root)/bin/$BIN_STACK" "$BIN_TARGET" From 053cab0c62095dabf358aaefc4cfd9ac4cbc4ebd Mon Sep 17 00:00:00 2001 From: Xavier Mitault <xavier.mitault@epitech.eu> Date: Wed, 29 Nov 2023 20:07:28 +0000 Subject: [PATCH 10/23] Fix args not passed in makefile PATCH --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index dc2483e..1081620 100644 --- a/Makefile +++ b/Makefile @@ -23,9 +23,9 @@ all: $(TARGET) $(TARGET): ifeq ($(OS),Windows_NT) - ./scripts/Build.ps1 + ./scripts/Build.ps1 $(BIN_STACK) $(BIN_TARGET) else - ./scripts/Build.sh + ./scripts/Build.sh $(BIN_STACK) $(BIN_TARGET) endif $(CP) "$(BIN_TARGET)" "$(MARVIN_TARGET)" From f72706cf262e5407b3d106229d8cb7c9d995ed94 Mon Sep 17 00:00:00 2001 From: Xavier Mitault <xavier.mitault@epitech.eu> Date: Wed, 29 Nov 2023 20:24:10 +0000 Subject: [PATCH 11/23] Fix windows PATCH --- Makefile | 12 +++--------- scripts/Build.ps1 | 8 -------- scripts/Build.sh | 8 -------- 3 files changed, 3 insertions(+), 25 deletions(-) delete mode 100644 scripts/Build.ps1 delete mode 100755 scripts/Build.sh diff --git a/Makefile b/Makefile index 1081620..faf66cf 100644 --- a/Makefile +++ b/Makefile @@ -13,28 +13,22 @@ RM = rm -rf ifeq ($(OS),Windows_NT) BIN_STACK = $(TARGET)-exe.exe - BIN_TARGET = $(TARGET).exe else BIN_STACK = $(TARGET)-exe - BIN_TARGET = $(TARGET) endif all: $(TARGET) $(TARGET): -ifeq ($(OS),Windows_NT) - ./scripts/Build.ps1 $(BIN_STACK) $(BIN_TARGET) -else - ./scripts/Build.sh $(BIN_STACK) $(BIN_TARGET) -endif - $(CP) "$(BIN_TARGET)" "$(MARVIN_TARGET)" + stack build --copy-bins --local-bin-path . + $(CP) "$(BIN_STACK)" "$(MARVIN_TARGET)" clean: stack clean fclean: clean stack purge - $(RM) "$(BIN_TARGET)" + $(RM) "$(BIN_STACK)" $(RM) "$(MARVIN_TARGET)" re: fclean $(TARGET) diff --git a/scripts/Build.ps1 b/scripts/Build.ps1 deleted file mode 100644 index b7fe730..0000000 --- a/scripts/Build.ps1 +++ /dev/null @@ -1,8 +0,0 @@ -$binStack = $args[0] -$binTarget = $args[1] - -stack build - -$pathLocalRoot = stack path --local-install-root - -Copy-Item "$pathLocalRoot/bin/$binStack" "$binTarget" diff --git a/scripts/Build.sh b/scripts/Build.sh deleted file mode 100755 index cebe263..0000000 --- a/scripts/Build.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -BIN_STACK="$1" -BIN_TARGET="$2" - -stack build - -cp "$(stack path --local-install-root)/bin/$BIN_STACK" "$BIN_TARGET" From d1f4ddbeeea1f8edbb5fd30f7a4da0ea9cbc77cf Mon Sep 17 00:00:00 2001 From: Xavier Mitault <xavier.mitault@epitech.eu> Date: Wed, 29 Nov 2023 20:33:03 +0000 Subject: [PATCH 12/23] Fix release PATCH --- .github/workflows/release.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f262282..df632a1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -59,7 +59,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - gh release upload ${{ needs.release-create.outputs.release }} "./koaky.exe#koaky-windows.exe" + gh release upload ${{ needs.release-create.outputs.release }} "./koaky-exe.exe#koaky-windows.exe" - name: Upload To Artifact if: github.ref != 'refs/heads/main' @@ -89,7 +89,7 @@ jobs: run: make - name: Rename - run: mv koaky koaky-linux + run: mv koaky-exe koaky-linux - name: Upload To Release if: github.ref == 'refs/heads/main' @@ -126,7 +126,7 @@ jobs: run: make - name: Rename - run: mv koaky koaky-macos + run: mv koaky-exe koaky-macos - name: Upload To Release if: github.ref == 'refs/heads/main' From 5a207cf3190a7472c4e943001039c70d0f5c01c4 Mon Sep 17 00:00:00 2001 From: Xavier Mitault <xavier.mitault@epitech.eu> Date: Fri, 1 Dec 2023 18:26:22 +0000 Subject: [PATCH 13/23] Test --- abc.test | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 abc.test diff --git a/abc.test b/abc.test new file mode 100644 index 0000000..e69de29 From 8602c7c56b287a010480151ae1975f2548581d0e Mon Sep 17 00:00:00 2001 From: Xavier Mitault <xavier.mitault@epitech.eu> Date: Fri, 1 Dec 2023 18:33:47 +0000 Subject: [PATCH 14/23] Fix norm yaml CI FIX --- .github/workflows/norm.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/norm.yml b/.github/workflows/norm.yml index d35a138..be7d139 100644 --- a/.github/workflows/norm.yml +++ b/.github/workflows/norm.yml @@ -26,13 +26,13 @@ jobs: - name: Send coding style message Ok uses: mshick/add-pr-comment@v2 - if: ${{ steps.isEmpty.outputs.isEmpty == "true" }} + if: steps.isEmpty.outputs.isEmpty == "true" with: message: "No coding style issue" - name: Send coding style message KO uses: mshick/add-pr-comment@v2 - if: ${{ steps.isEmpty.outputs.isEmpty == "false" }} + if: steps.isEmpty.outputs.isEmpty == "false" with: message-path: | coding-style-reports.log From 1f668da0ee0a7171360cbbfbb97c2c2305ec4571 Mon Sep 17 00:00:00 2001 From: Xavier Mitault <xavier.mitault@epitech.eu> Date: Fri, 1 Dec 2023 18:35:04 +0000 Subject: [PATCH 15/23] Fix image name on CI PATCH --- .github/workflows/norm.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/norm.yml b/.github/workflows/norm.yml index be7d139..8872b6f 100644 --- a/.github/workflows/norm.yml +++ b/.github/workflows/norm.yml @@ -6,7 +6,7 @@ jobs: norm: runs-on: ubuntu-latest - image: ghcr.io/epitech/coding-style-checker:latest + container: ghcr.io/epitech/coding-style-checker:latest steps: - name: Checkout From 44ff727ec603456b5d1dc141a2468dd95f98c48d Mon Sep 17 00:00:00 2001 From: Xavier Mitault <xavier.mitault@epitech.eu> Date: Fri, 1 Dec 2023 18:37:44 +0000 Subject: [PATCH 16/23] Change condition in CI PATCH --- .github/workflows/norm.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/norm.yml b/.github/workflows/norm.yml index 8872b6f..f08d92b 100644 --- a/.github/workflows/norm.yml +++ b/.github/workflows/norm.yml @@ -26,13 +26,13 @@ jobs: - name: Send coding style message Ok uses: mshick/add-pr-comment@v2 - if: steps.isEmpty.outputs.isEmpty == "true" + if: steps.isEmpty.outputs.isEmpty == 'true' with: message: "No coding style issue" - name: Send coding style message KO uses: mshick/add-pr-comment@v2 - if: steps.isEmpty.outputs.isEmpty == "false" + if: steps.isEmpty.outputs.isEmpty == 'false' with: message-path: | coding-style-reports.log From 9850ad4daa05ec91dc36e3e46dd26f8fdd8ac27c Mon Sep 17 00:00:00 2001 From: Xavier Mitault <xavier.mitault@epitech.eu> Date: Sat, 2 Dec 2023 12:58:57 +0000 Subject: [PATCH 17/23] Fix norm CICD PATCH --- .github/workflows/norm.yml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/norm.yml b/.github/workflows/norm.yml index f08d92b..383d76b 100644 --- a/.github/workflows/norm.yml +++ b/.github/workflows/norm.yml @@ -1,24 +1,29 @@ name: Norm on: [pull_request] - + # lambdananas -o vera --exclude "Setup.hs:setup.hs:.git:.stack-work:test:tests:bonus" . >> lambdananas-reports.log jobs: norm: runs-on: ubuntu-latest - container: ghcr.io/epitech/coding-style-checker:latest steps: - name: Checkout uses: actions/checkout@v2 + + - name: Install Deps + run: | + sudo apt-get update && sudo apt-get install -y curl + curl -fsSL 'https://github.com/Saverio976/dotfiles/raw/main/.local/bin/lambdananas' > /tmp/lambdananas + chmod +x /tmp/lambdananas - name: Format - run: code-style-haskell.sh . . + run: /tmp/lambdananas -o vera --exclude "Setup.hs:setup.hs:.git:.stack-work:test:tests:bonus" . >> lambdananas-reports.log - name: Is Empty id: isEmpty run: | - if [ "$(cat coding-style-reports.log)" == "" ]; then + if [ "$(cat lambdananas-reports.log)" == "" ]; then echo "isEmpty=true" >> $GITHUB_OUTPUT else echo "isEmpty=false" >> $GITHUB_OUTPUT @@ -35,4 +40,4 @@ jobs: if: steps.isEmpty.outputs.isEmpty == 'false' with: message-path: | - coding-style-reports.log + lambdananas-reports.log From 58fe5bc7b311d3b541031571ceeb08daa214e13f Mon Sep 17 00:00:00 2001 From: Xavier Mitault <xavier.mitault@epitech.eu> Date: Sat, 2 Dec 2023 13:01:44 +0000 Subject: [PATCH 18/23] Add exit bad if coding style error MINOR --- .github/workflows/norm.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/norm.yml b/.github/workflows/norm.yml index 383d76b..837b3ff 100644 --- a/.github/workflows/norm.yml +++ b/.github/workflows/norm.yml @@ -41,3 +41,9 @@ jobs: with: message-path: | lambdananas-reports.log + + - name: Exit Status + run: | + if [ ${{ steps.isEmpty.outputs.isEmpty }} == 'false' ]; then + exit 1 + fi From 415ee1eb64f905482da3a8bd1f6d7d205c347563 Mon Sep 17 00:00:00 2001 From: Xavier Mitault <xavier.mitault@epitech.eu> Date: Sat, 2 Dec 2023 13:06:14 +0000 Subject: [PATCH 19/23] Fix haskell bad formated header PATCH --- .gitignore | 1 + app/Main.hs | 8 ++++---- src/AST.hs | 8 ++++---- src/ComputeAST.hs | 8 ++++---- src/TextToAST.hs | 8 ++++---- 5 files changed, 17 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index 170268a..826e993 100644 --- a/.gitignore +++ b/.gitignore @@ -173,3 +173,4 @@ tags /make.exe /libssp-0.dll +lambdananas-reports.log diff --git a/app/Main.hs b/app/Main.hs index 8f4b288..8c240f6 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -1,8 +1,8 @@ {- --- EPITECH PROJECT, 2023 --- Main --- File description: --- Main +-- EPITECH PROJECT, 2023 +-- Main +-- File description: +-- Main -} module Main (main) where diff --git a/src/AST.hs b/src/AST.hs index a1cf1ff..3830c15 100644 --- a/src/AST.hs +++ b/src/AST.hs @@ -1,8 +1,8 @@ {- --- EPITECH PROJECT, 2023 --- Abstract Syntax Tree --- File description: --- ast +-- EPITECH PROJECT, 2023 +-- Abstract Syntax Tree +-- File description: +-- ast -} module AST diff --git a/src/ComputeAST.hs b/src/ComputeAST.hs index 97eff66..fe2a59c 100644 --- a/src/ComputeAST.hs +++ b/src/ComputeAST.hs @@ -1,8 +1,8 @@ {- --- EPITECH PROJECT, 2023 --- Compute an AST --- File description: --- ComputeAST +-- EPITECH PROJECT, 2023 +-- Compute an AST +-- File description: +-- ComputeAST -} module ComputeAST diff --git a/src/TextToAST.hs b/src/TextToAST.hs index 3921b15..4b06767 100644 --- a/src/TextToAST.hs +++ b/src/TextToAST.hs @@ -1,8 +1,8 @@ {- --- EPITECH PROJECT, 2023 --- Text To AST --- File description: --- TextToAST +-- EPITECH PROJECT, 2023 +-- Text To AST +-- File description: +-- TextToAST -} module TextToAST From 7879e69b416ccef62630d79780cf430d798382a8 Mon Sep 17 00:00:00 2001 From: Xavier Mitault <xavier.mitault@epitech.eu> Date: Sat, 2 Dec 2023 16:16:19 +0000 Subject: [PATCH 20/23] Add basic test for ast MINOR --- abc.test | 0 koaky.cabal | 22 +++++++++------------- package.yaml | 10 ++++++---- src/AST.hs | 18 ++++++++++++++++++ test/Spec.hs | 20 +++++++++++++++++++- 5 files changed, 52 insertions(+), 18 deletions(-) delete mode 100644 abc.test diff --git a/abc.test b/abc.test deleted file mode 100644 index e69de29..0000000 diff --git a/koaky.cabal b/koaky.cabal index 512296a..92343d7 100644 --- a/koaky.cabal +++ b/koaky.cabal @@ -1,4 +1,4 @@ -cabal-version: 2.2 +cabal-version: 1.12 -- This file has been generated from package.yaml by hpack version 0.36.0. -- @@ -7,12 +7,12 @@ cabal-version: 2.2 name: koaky version: 0.1.0.0 description: Please see the README on GitHub at <https://github.com/githubuser/koaky#readme> -homepage: https://github.com/githubuser/koaky#readme -bug-reports: https://github.com/githubuser/koaky/issues -author: Author name here +homepage: https://github.com/X-R-G-B/koaky#readme +bug-reports: https://github.com/X-R-G-B/koaky/issues +author: @guillaumeAbel, @TTENSHII, @Saverio976 maintainer: example@example.com -copyright: 2023 Author name here -license: BSD-3-Clause +copyright: 2023 X-R-G-B +license: MIT license-file: LICENSE build-type: Simple extra-source-files: @@ -21,7 +21,7 @@ extra-source-files: source-repository head type: git - location: https://github.com/githubuser/koaky + location: https://github.com/X-R-G-B/koaky library exposed-modules: @@ -30,8 +30,6 @@ library TextToAST other-modules: Paths_koaky - autogen-modules: - Paths_koaky hs-source-dirs: src ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints @@ -43,8 +41,6 @@ executable koaky-exe main-is: Main.hs other-modules: Paths_koaky - autogen-modules: - Paths_koaky hs-source-dirs: app ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-N @@ -58,12 +54,12 @@ test-suite koaky-test main-is: Spec.hs other-modules: Paths_koaky - autogen-modules: - Paths_koaky hs-source-dirs: test ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-N build-depends: base >=4.7 && <5 , koaky + , tasty + , tasty-hunit default-language: Haskell2010 diff --git a/package.yaml b/package.yaml index 334f2c4..a2e4fa0 100644 --- a/package.yaml +++ b/package.yaml @@ -1,10 +1,10 @@ name: koaky version: 0.1.0.0 -github: "githubuser/koaky" -license: BSD-3-Clause -author: "Author name here" +github: "X-R-G-B/koaky" +license: MIT +author: "@guillaumeAbel, @TTENSHII, @Saverio976" maintainer: "example@example.com" -copyright: "2023 Author name here" +copyright: "2023 X-R-G-B" extra-source-files: - README.md @@ -57,3 +57,5 @@ tests: - -with-rtsopts=-N dependencies: - koaky + - tasty + - tasty-hunit diff --git a/src/AST.hs b/src/AST.hs index 3830c15..bf6f5a8 100644 --- a/src/AST.hs +++ b/src/AST.hs @@ -19,3 +19,21 @@ type Symbol = String data Atom = Number Int64 | Symbol Symbol data Tree = Node Symbol [Tree] | Leaf Atom + +instance Eq Atom where + Number a == Number b = a == b + Symbol a == Symbol b = a == b + _ == _ = False + +instance Show Atom where + show (Number a) = "Number:'" ++ show a ++ "'" + show (Symbol a) = "Symbol:'" ++ a ++ "'" + +instance Eq Tree where + Node a as == Node b bs = a == b && as == bs + Leaf a == Leaf b = a == b + _ == _ = False + +instance Show Tree where + show (Node a as) = "Node:'" ++ a ++ "'{" ++ show as ++ "}" + show (Leaf a) = "Leaf:'" ++ show a ++ "'" diff --git a/test/Spec.hs b/test/Spec.hs index cd4753f..8842279 100644 --- a/test/Spec.hs +++ b/test/Spec.hs @@ -1,2 +1,20 @@ +import Test.Tasty +import Test.Tasty.HUnit + +import AST + main :: IO () -main = putStrLn "Test suite not yet implemented" +main = defaultMain tests + +tests :: TestTree +tests = testGroup "Tests" [unitTests] + +unitTests :: TestTree +unitTests = testGroup "Unit tests" + [ testCase "Basic AST creation 0" $ + assertEqual "define x 42" (Node "define" [Leaf (Symbol "x"), Leaf (Number 42)]) (Node "define" [Leaf (Symbol "x"), Leaf (Number 42)]) + , testCase "Basic AST creation 1" $ + assertEqual "foo" (Leaf (Symbol "foo")) (Leaf (Symbol "foo")) + , testCase "Basic AST creation 2" $ + assertEqual "42" (Leaf (Number 42)) (Leaf (Number 42)) + ] From 9eadfe1431152c0f0260ab3be120c83e16c2977c Mon Sep 17 00:00:00 2001 From: Xavier Mitault <xavier.mitault@epitech.eu> Date: Sat, 2 Dec 2023 17:28:48 +0000 Subject: [PATCH 21/23] Fix stack package and tests + add test on CICD MINOR --- .github/workflows/compil.yml | 2 +- .github/workflows/documentation.yml | 20 +++++++ .github/workflows/norm.yml | 2 + .github/workflows/tests.yml | 86 +++++++++++++++++++++++++++++ Makefile | 3 + docs/SUMMARY.md | 4 ++ docs/Tests.md | 1 + koaky.cabal | 1 + package.yaml | 1 + stack.yaml | 8 ++- stack.yaml.lock | 32 +++++++++-- test/Spec.hs | 3 +- 12 files changed, 152 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/tests.yml create mode 100644 docs/Tests.md diff --git a/.github/workflows/compil.yml b/.github/workflows/compil.yml index 06faaca..9c41b7a 100644 --- a/.github/workflows/compil.yml +++ b/.github/workflows/compil.yml @@ -25,7 +25,7 @@ jobs: - '.github/workflows/**' src: - '*.hs' - cmake: + make: - 'Makefile' compil-windows: diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index 017b93a..267b8cb 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -48,6 +48,26 @@ jobs: if: steps.filter.outputs.docs == 'true' || steps.filter.outputs.docs2 == 'true' || steps.filter.outputs.workflow == 'true' || github.ref == 'refs/heads/main' run: mdbook build + - name: Install Haskell + uses: haskell-actions/setup@v2 + with: + enable-stack: true + stack-version: 'latest' + + - name: Compil + if: steps.filter.outputs.docs == 'true' || steps.filter.outputs.docs2 == 'true' || steps.filter.outputs.workflow == 'true' || github.ref == 'refs/heads/main' + run: | + if ! stack build; then + exit 0 + fi + + - name: Tests + if: steps.filter.outputs.docs == 'true' || steps.filter.outputs.docs2 == 'true' || steps.filter.outputs.workflow == 'true' || github.ref == 'refs/heads/main' + run: | + if ! stack test --test-arguments "--html book/Tests.html"; then + exit 0 + fi + - name: Setup Pages if: github.ref == 'refs/heads/main' uses: actions/configure-pages@v3 diff --git a/.github/workflows/norm.yml b/.github/workflows/norm.yml index 837b3ff..b33164d 100644 --- a/.github/workflows/norm.yml +++ b/.github/workflows/norm.yml @@ -34,6 +34,7 @@ jobs: if: steps.isEmpty.outputs.isEmpty == 'true' with: message: "No coding style issue" + refresh-message-position: true - name: Send coding style message KO uses: mshick/add-pr-comment@v2 @@ -41,6 +42,7 @@ jobs: with: message-path: | lambdananas-reports.log + refresh-message-position: true - name: Exit Status run: | diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..59ae695 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,86 @@ +name: Tests + +on: [pull_request] + +jobs: + compil-check-job-run: + runs-on: ubuntu-latest + + outputs: + workflows: ${{ steps.filter.outputs.workflows }} + src: ${{ steps.filter.outputs.src }} + make: ${{ steps.filter.outputs.make }} + package: ${{ steps.filter.outputs.package }} + stack: ${{ steps.filter.outputs.stack }} + combined: ${{ steps.filter.outputs.workflows == 'true' || steps.filter.outputs.src == 'true' || steps.filter.outputs.make == 'true' }} || steps.filter.outputs.package == 'true' || steps.filter.outputs.stack == 'true' + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Check modified files need re run + id: filter + uses: dorny/paths-filter@v2 + with: + filters: | + workflows: + - '.github/workflows/**' + src: + - '*.hs' + make: + - 'Makefile' + package: + - 'package.yaml' + stack: + - 'stack.yaml' + + tests: + runs-on: ubuntu-latest + needs: [compil-check-job-run] + if: needs.compil-check-job-run.outputs.combined + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install Haskell + uses: haskell-actions/setup@v2 + with: + enable-stack: true + stack-version: 'latest' + + - name: Install dependencies + run: sudo ./scripts/InstallDepsLinux.bash + + - name: Compil + run: make + + - name: Tests + id: failedTest + run: | + if ! stack test &> tests.log; then + echo "failedTest=true" >> $GITHUB_OUTPUT + else + echo "failedTest=false" >> $GITHUB_OUTPUT + fi + + - name: Upload stats + uses: actions/upload-artifact@v3 + with: + name: tests.log + path: tests.log + + - name: Send Test Ok + uses: mshick/add-pr-comment@v2 + if: steps.failedTest.outputs.failedTest == 'false' + with: + message: "Tests PASSED" + refresh-message-position: true + + - name: Send Test KO + uses: mshick/add-pr-comment@v2 + if: steps.failedTest.outputs.failedTest == 'true' + with: + message-path: | + tests.log + refresh-message-position: true diff --git a/Makefile b/Makefile index faf66cf..96bb1b1 100644 --- a/Makefile +++ b/Makefile @@ -33,4 +33,7 @@ fclean: clean re: fclean $(TARGET) +tests: + stack test + .PHONY: $(TARGET) fclean re clean all diff --git a/docs/SUMMARY.md b/docs/SUMMARY.md index ef6ac93..6b4a296 100644 --- a/docs/SUMMARY.md +++ b/docs/SUMMARY.md @@ -1,3 +1,7 @@ # Summary +This is a new amazing programming language +made in Haskell. + [README](README.md) +[Tests](Tests.md) diff --git a/docs/Tests.md b/docs/Tests.md new file mode 100644 index 0000000..3bccffe --- /dev/null +++ b/docs/Tests.md @@ -0,0 +1 @@ +# this will be overwiten by the tests ... diff --git a/koaky.cabal b/koaky.cabal index 92343d7..7cccb21 100644 --- a/koaky.cabal +++ b/koaky.cabal @@ -61,5 +61,6 @@ test-suite koaky-test base >=4.7 && <5 , koaky , tasty + , tasty-html , tasty-hunit default-language: Haskell2010 diff --git a/package.yaml b/package.yaml index a2e4fa0..a961c6a 100644 --- a/package.yaml +++ b/package.yaml @@ -59,3 +59,4 @@ tests: - koaky - tasty - tasty-hunit + - tasty-html diff --git a/stack.yaml b/stack.yaml index 48acbf9..a34bc4c 100644 --- a/stack.yaml +++ b/stack.yaml @@ -17,8 +17,7 @@ # # resolver: ./custom-snapshot.yaml # resolver: https://example.com/snapshots/2023-01-01.yaml -resolver: - url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/21/22.yaml +resolver: lts-21.13 # User packages to be built. # Various formats can be used as shown in the example below. @@ -40,7 +39,10 @@ packages: # - git: https://github.com/commercialhaskell/stack.git # commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a # -# extra-deps: [] +extra-deps: +- tasty-1.4.2.2 +- tasty-hunit-0.10.1 +- tasty-html-0.4.2.1 # Override default flag values for local packages and extra-deps # flags: {} diff --git a/stack.yaml.lock b/stack.yaml.lock index b21f704..92ef11f 100644 --- a/stack.yaml.lock +++ b/stack.yaml.lock @@ -3,11 +3,31 @@ # For more information, please see the documentation at: # https://docs.haskellstack.org/en/stable/lock_files -packages: [] -snapshots: +packages: +- completed: + hackage: tasty-1.4.2.2@sha256:b987609178d70c0042b950302161a049be8a878aa8cee4a9c7ba81d22d29a3f5,2719 + pantry-tree: + sha256: a93f5e31aac66a82a885cb2ddc8eada9a8adefe8587da1c4085fae58b6bc4683 + size: 1944 + original: + hackage: tasty-1.4.2.2 - completed: - sha256: afd5ba64ab602cabc2d3942d3d7e7dd6311bc626dcb415b901eaf576cb62f0ea - size: 640060 - url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/21/22.yaml + hackage: tasty-hunit-0.10.1@sha256:ebc17b490750d4796b21d44001b852688cc39f9c34e387d5e7958e09b9b3f3b9,1602 + pantry-tree: + sha256: c00ed23d8281b6c6f4ec33dd1e9e3a7971b0a769b6140978cfaf2a6eff025c78 + size: 399 original: - url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/21/22.yaml + hackage: tasty-hunit-0.10.1 +- completed: + hackage: tasty-html-0.4.2.1@sha256:92ded1b794bfd6a46d5705f418c531f51aba3907b92d68a28aed349fc03a8e0d,1599 + pantry-tree: + sha256: 88f745a7d4904c2f663baeadb3fe14ec0986c02341b2663d7e7051a680fdca3c + size: 547 + original: + hackage: tasty-html-0.4.2.1 +snapshots: +- completed: + sha256: 8017c7970c2a8a9510c60cc70ac245d59e0c34eb932b91d37af09fe59855d854 + size: 640038 + url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/21/13.yaml + original: lts-21.13 diff --git a/test/Spec.hs b/test/Spec.hs index 8842279..d7ca972 100644 --- a/test/Spec.hs +++ b/test/Spec.hs @@ -1,10 +1,11 @@ import Test.Tasty import Test.Tasty.HUnit +import Test.Tasty.Runners.Html import AST main :: IO () -main = defaultMain tests +main = defaultMainWithIngredients (htmlRunner : defaultIngredients) tests tests :: TestTree tests = testGroup "Tests" [unitTests] From 2c2a2fb5c22b4c7fa6ecf10a413d429ca2144d53 Mon Sep 17 00:00:00 2001 From: Xavier Mitault <xavier.mitault@epitech.eu> Date: Sat, 2 Dec 2023 18:59:14 +0000 Subject: [PATCH 22/23] Fix message overwriten PATCH --- .github/workflows/norm.yml | 2 ++ .github/workflows/tests.yml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/.github/workflows/norm.yml b/.github/workflows/norm.yml index b33164d..6739e83 100644 --- a/.github/workflows/norm.yml +++ b/.github/workflows/norm.yml @@ -35,6 +35,7 @@ jobs: with: message: "No coding style issue" refresh-message-position: true + message-id: norm-cicd - name: Send coding style message KO uses: mshick/add-pr-comment@v2 @@ -43,6 +44,7 @@ jobs: message-path: | lambdananas-reports.log refresh-message-position: true + message-id: norm-cicd - name: Exit Status run: | diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 59ae695..b89f8ee 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -76,6 +76,7 @@ jobs: with: message: "Tests PASSED" refresh-message-position: true + message-id: tests-cicd - name: Send Test KO uses: mshick/add-pr-comment@v2 @@ -84,3 +85,4 @@ jobs: message-path: | tests.log refresh-message-position: true + message-id: tests-cicd From e0aac41b7023528a98495bf88318fbf049e0b89a Mon Sep 17 00:00:00 2001 From: Xavier Mitault <xavier.mitault@epitech.eu> Date: Sat, 2 Dec 2023 20:29:02 +0000 Subject: [PATCH 23/23] Add flags PATCH --- koaky.cabal | 6 +++--- package.yaml | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/koaky.cabal b/koaky.cabal index 7cccb21..b9d8583 100644 --- a/koaky.cabal +++ b/koaky.cabal @@ -32,7 +32,7 @@ library Paths_koaky hs-source-dirs: src - ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints + ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints -Wdefault -W -Woperator-whitespace build-depends: base >=4.7 && <5 default-language: Haskell2010 @@ -43,7 +43,7 @@ executable koaky-exe Paths_koaky hs-source-dirs: app - ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-N + ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints -Wdefault -W -Woperator-whitespace -threaded -rtsopts -with-rtsopts=-N build-depends: base >=4.7 && <5 , koaky @@ -56,7 +56,7 @@ test-suite koaky-test Paths_koaky hs-source-dirs: test - ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-N + ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints -Wdefault -W -Woperator-whitespace -threaded -rtsopts -with-rtsopts=-N build-depends: base >=4.7 && <5 , koaky diff --git a/package.yaml b/package.yaml index a961c6a..b4a3ae8 100644 --- a/package.yaml +++ b/package.yaml @@ -32,6 +32,9 @@ ghc-options: - -Wmissing-home-modules - -Wpartial-fields - -Wredundant-constraints +- -Wdefault +- -W +- -Woperator-whitespace library: source-dirs: src