From 03b40eb97645e91a123c81bec5ba05c3bb6d02f9 Mon Sep 17 00:00:00 2001 From: Siddhartha Date: Tue, 8 Jun 2021 10:34:59 -0700 Subject: [PATCH] makefile and CI workflow --- .github/workflows/test.yml | 60 ++++++++++++++++++++++++++++ Makefile | 82 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 142 insertions(+) create mode 100644 .github/workflows/test.yml create mode 100644 Makefile diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..18455dd --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,60 @@ +name: build + +on: [push, pull_request] + +defaults: + run: + shell: bash + +jobs: + test: + runs-on: ubuntu-latest + continue-on-error: ${{ matrix.experimental }} + strategy: + fail-fast: true + matrix: + racket-variant: ['BC', 'CS'] + racket-version: ['7.8', 'stable'] + experimental: [false] + include: + - racket-version: 'current' + racket-variant: 'CS' + experimental: true + name: Test on Racket ${{ matrix.racket-variant }} ${{ matrix.racket-version }} + steps: + - name: Checkout + uses: actions/checkout@master + - name: Install Racket + uses: Bogdanp/setup-racket@v1.3.1 + with: + architecture: 'x64' + distribution: 'full' + variant: ${{ matrix.racket-variant }} + version: ${{ matrix.racket-version }} + - name: Install Package and its Dependencies + run: make install + - name: Check Dependencies + run: make check-deps + - name: Run Tests + run: make test + coverage: + needs: test + runs-on: ubuntu-latest + name: Report Coverage + environment: test-env + env: + COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} + steps: + - name: Checkout + uses: actions/checkout@master + - name: Install Racket + uses: Bogdanp/setup-racket@v1.3.1 + with: + architecture: 'x64' + distribution: 'full' + variant: 'CS' + version: 'stable' + - name: Install Package and its Dependencies + run: make install + - name: Report Coverage + run: make cover-coveralls diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..53fe90f --- /dev/null +++ b/Makefile @@ -0,0 +1,82 @@ +# Adapted from: http://www.greghendershott.com/2017/04/racket-makefiles.html +PACKAGE-NAME=cli + +DEPS-FLAGS=--check-pkg-deps --unused-pkg-deps + +help: + @echo "install - install package along with dependencies" + @echo "remove - remove package" + @echo "build - Compile libraries" + @echo "build-docs - Build docs" + @echo "build-all - Compile libraries, build docs, and check dependencies" + @echo "clean - remove all build artifacts" + @echo "check-deps - check dependencies" + @echo "test - run tests" + @echo "test-with-errortrace - run tests with error tracing" + @echo "errortrace - alias for test-with-errortrace" + @echo "cover - Run test coverage checker and view report" + @echo "cover-coveralls - Run test coverage and upload to Coveralls" + @echo "coverage-check - Run test coverage checker" + @echo "coverage-report - View test coverage report" + @echo "docs - view docs in a browser" + +# Primarily for use by CI. +# Installs dependencies as well as linking this as a package. +install: + raco pkg install --deps search-auto + +remove: + raco pkg remove $(PACKAGE-NAME) + +# Primarily for day-to-day dev. +# Build libraries from source. +build: + raco setup --no-docs --tidy --pkgs $(PACKAGE-NAME) + +# Primarily for day-to-day dev. +# Build docs (if any). +build-docs: + raco setup --no-launcher --no-foreign-libs --no-info-domain --no-pkg-deps \ + --no-install --no-post-install --tidy --pkgs $(PACKAGE-NAME) + +# Primarily for day-to-day dev. +# Build libraries from source, build docs (if any), and check dependencies. +build-all: + raco setup --tidy $(DEPS-FLAGS) --pkgs $(PACKAGE-NAME) + +# Note: Each collection's info.rkt can say what to clean, for example +# (define clean '("compiled" "doc" "doc/")) to clean +# generated docs, too. +clean: + raco setup --fast-clean --pkgs $(PACKAGE-NAME) + +# Primarily for use by CI, after make install -- since that already +# does the equivalent of make setup, this tries to do as little as +# possible except checking deps. +check-deps: + raco setup --no-docs $(DEPS-FLAGS) $(PACKAGE-NAME) + +# Suitable for both day-to-day dev and CI +test: + raco test -x -p $(PACKAGE-NAME) + +test-with-errortrace: + racket -l errortrace -l racket -e '(require (submod "main.rkt" test))' + +errortrace: test-with-errortrace + +docs: + raco docs $(PACKAGE-NAME) + +coverage-check: + raco cover -b -n dev -p $(PACKAGE-NAME) + +coverage-report: + open coverage/index.html + +cover: coverage-check coverage-report + +cover-coveralls: + raco cover -b -n dev -f coveralls -p $(PACKAGE-NAME) + +.PHONY: help install remove build build-docs build-all clean check-deps test test-with-errortrace errortrace docs cover coverage-check coverage-report cover-coveralls