diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fa5cd6dbb..a7c4751c3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,23 +11,40 @@ concurrency: jobs: build: - runs-on: ubuntu-latest + strategy: + matrix: + os: [linux] + + include: + - os: linux + runner: ubuntu-latest + + runs-on: ${{ matrix.runner }} + steps: - - uses: actions/checkout@v3 - - uses: freckle/stack-cache-action@v2 + - uses: actions/checkout@v4 - id: stack - uses: freckle/stack-action@v3 + uses: freckle/stack-action@v5 - uses: freckle/weeder-action@v2 with: ghc-version: ${{ steps.stack.outputs.compiler-version }} + - run: | + dist=restyler-$(uname -s | tr '[:upper:]' '[:lower:]')-$(uname -m) + mkdir -p "$dist" + cp -v ${{ steps.stack.outputs.local-install-root }}/bin/* "$dist" + tar czf "$dist.tar.gz" "$dist" + - uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.os }}-binaries + path: "restyler-*.tar.gz" + if-no-files-found: error lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - run: curl -L https://raw.githubusercontent.com/pbrisbin/dotfiles/master/hlint.yaml > .hlint.yaml - - uses: haskell/actions/hlint-setup@v2 - - uses: haskell/actions/hlint-run@v2 + - uses: actions/checkout@v4 + - uses: haskell-actions/hlint-setup@v2 + - uses: haskell-actions/hlint-run@v2 with: fail-on: warning @@ -35,7 +52,7 @@ jobs: runs-on: ubuntu-latest steps: - id: meta - uses: docker/metadata-action@v3 + uses: docker/metadata-action@v5 with: images: restyled/restyler tags: | @@ -43,35 +60,21 @@ jobs: type=edge,branch=main type=ref,event=tag - - id: buildx - uses: docker/setup-buildx-action@v1 - - - uses: actions/cache@v3 - with: - path: /tmp/.buildx-cache - key: ${{ runner.os }}-image-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-image- + - uses: docker/setup-buildx-action@v3 - - uses: docker/login-action@v1 + - uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} - - uses: docker/build-push-action@v2 + - uses: docker/build-push-action@v5 with: - builder: ${{ steps.buildx.outputs.name }} - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new + cache-from: type=gha + cache-to: type=gha,mode=max push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - # Avoids ever-growing cache hitting limits - - run: | - rm -rf /tmp/.buildx-cache - mv /tmp/.buildx-cache-new /tmp/.buildx-cache - outputs: tags: ${{ steps.meta.outputs.tags }} @@ -109,3 +112,23 @@ jobs: job-status: ${{ job.status }} pushover-api-token: ${{ secrets.PUSHOVER_API_TOKEN }} pushover-user-key: ${{ secrets.PUSHOVER_USER_KEY }} + + release: + # TESTING + # if: ${{ github.ref == 'refs/heads/main' }} + runs-on: ubuntu-latest + + needs: [build] + steps: + - uses: actions/checkout@v4 + - id: tag + uses: freckle/haskell-tag-action@v1 + - if: steps.tag.outputs.tag + uses: actions/download-artifact@v4 + - if: steps.tag.outputs.tag + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ steps.tag.outputs.tag }} + generate_release_notes: true + files: "*-binaries/restyler-*.tar.gz" + fail_on_unmatched_files: true diff --git a/.hlint.yaml b/.hlint.yaml new file mode 100644 index 000000000..b1e8e7183 --- /dev/null +++ b/.hlint.yaml @@ -0,0 +1,2 @@ +- ignore: + name: Functor law diff --git a/Makefile b/Makefile deleted file mode 100644 index 09d3507fd..000000000 --- a/Makefile +++ /dev/null @@ -1,83 +0,0 @@ -all: setup setup.lint setup.tools build lint test - -.PHONY: setup -setup: - stack setup - stack build --dependencies-only --test --no-run-tests - -.PHONY: setup.lint -setup.lint: - stack install --copy-compiler-tool hlint weeder - -.PHONY: setup.tools -setup.tools: - stack install --copy-compiler-tool \ - brittany \ - fast-tags \ - stylish-haskell - -.PHONY: build -build: - stack build --pedantic --test --no-run-tests - -.PHONY: lint -lint: - stack exec hlint app src test - stack exec weeder . - -.PHONY: test -test: - stack build --test - -TEST_INTEGRATION_COMMAND ?= restyled -TEST_INTEGRATION_OPTIONS ?= stable - -# Example for using local SDK, etc: -# make test.integration \ -# TEST_INTEGRATION_COMMAND='stack --stack-yaml ../sdk/stack.yaml exec --' \ -# TEST_INTEGRATION_OPTIONS='--debug dev' - -.PHONY: test.integration -test.integration: image - AWS_PROFILE=restyled-ci $(TEST_INTEGRATION_COMMAND) promote \ - --image restyled/restyler:edge $(TEST_INTEGRATION_OPTIONS) - -.PHONY: watch -watch: - stack build --fast --pedantic --test --file-watch - -.PHONY: image -image: - docker buildx build \ - --tag restyled/restyler:edge \ - . - -AWS ?= aws --profile restyled-ci - -DOC_BUCKET = $(shell \ - $(AWS) cloudformation describe-stacks \ - --stack-name sites-docs \ - --query 'Stacks[*].Outputs[?OutputKey==`BucketName`].OutputValue' \ - --output text \ -) - -DOC_DISTRIBUTION_ID = $(shell \ - $(AWS) cloudformation describe-stacks \ - --stack-name sites-docs \ - --query 'Stacks[*].Outputs[?OutputKey==`DistributionId`].OutputValue' \ - --output text \ -) - -DOC_ROOT = $(shell stack path --local-doc-root) -DOC_S3_PREFIX = /restyler - -.PHONY: docs -docs: - [ -n "$$STACK_WORK_DIR" ] - stack build --haddock - find "$$STACK_WORK_DIR" -type f -name '*.html' -exec \ - sed -i 's|$(DOC_ROOT)|$(DOC_S3_PREFIX)|g' {} + - $(AWS) s3 sync --acl public-read --delete $(DOC_ROOT)/ \ - s3://$(DOC_BUCKET)$(DOC_S3_PREFIX)/ - $(AWS) cloudfront create-invalidation \ - --distribution-id $(DOC_DISTRIBUTION_ID) --paths "$(DOC_S3_PREFIX)/*" diff --git a/README.md b/README.md index 84fe6571e..22faae454 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ will be authored by your user. ## Development ```console -make +just ``` Requires [stack](https://docs.haskellstack.org/en/stable/README/). @@ -29,7 +29,7 @@ Requires [stack](https://docs.haskellstack.org/en/stable/README/). ## Tests ```console -make test +just test ``` ### Integration @@ -37,7 +37,7 @@ make test End-to-end test that restyles an example Pull Request: ```console -make test.integration +just test-integration ``` ## `restyle-path` diff --git a/justfile b/justfile new file mode 100644 index 000000000..1cc17abee --- /dev/null +++ b/justfile @@ -0,0 +1,79 @@ +# Setup, lint, build and test +all: setup build test lint + +# Install dependencies +setup: + stack setup + stack build --dependencies-only --test --no-run-tests + stack install --copy-compiler-tool \ + apply-refact \ + fast-tags \ + fourmolu \ + hlint \ + weeder + +# Build but do not run tests +build: + stack build --fast --pedantic --test --no-run-tests + +# Build and test +test: + stack build --fast --pedantic --test + +# Lint and format the project +lint: + stack exec -- fourmolu -i app src test + stack exec -- hlint app src test + stack exec -- weeder --require-hs-files + stack lint-extra-deps + +# Rebuild and test on file-changes +watch: + stack build --fast --pedantic --test --file-watch + +# Build the Docker image +image: + docker build --tag restyled/restyler:edge . + +test_integration_command := "restyled" +test_integration_options := "stable" + +# Example for using local SDK, etc: + +# just test-integration \ +# test_integration_command='stack --stack-yaml ../sdk/stack.yaml exec --' \ +# test_integration_options='--debug dev' +# +[doc('Run integration tests against our demo real PR')] +test-integration: image + AWS_PROFILE=restyled-ci {{test_integration_command}} promote \ + --image restyled/restyler:edge {{test_integration_options}} + +# aws := "aws --profile restyled-ci" + +# doc_bucket := ` +# {{aws}} cloudformation describe-stacks \ +# --stack-name sites-docs \ +# --query 'Stacks[*].Outputs[?OutputKey==`BucketName`].OutputValue' \ +# --output text \ +# ` + +# doc_distribution_id := ` +# {{aws}} cloudformation describe-stacks \ +# --stack-name sites-docs \ +# --query 'Stacks[*].Outputs[?OutputKey==`DistributionId`].OutputValue' \ +# --output text \ +# ` + +# doc_root := `stack path --local-doc-root` +# doc_s3_prefix := /restyler + +# docs: +# [ -n "$$STACK_WORK_DIR" ] +# stack build --haddock +# find "$$STACK_WORK_DIR" -type f -name '*.html' -exec \ +# sed -i 's|{{doc_root}}|{{doc_s3_prefix}}|g' {} + +# {{aws}} s3 sync --acl public-read --delete {{doc_root}}/ \ +# s3://{{doc_bucket}}{{doc_s3_prefix}}/ +# {{aws}} cloudfront create-invalidation \ +# --distribution-id {{doc_distribution_id}} --paths "{{doc_s3_prefix}}/*" diff --git a/package.yaml b/package.yaml index 8081bbc28..7b3cb5f63 100644 --- a/package.yaml +++ b/package.yaml @@ -1,5 +1,5 @@ name: restyler -version: 0.2.0.0 +version: 0.2.1.0 license: MIT default-extensions: diff --git a/restyler.cabal b/restyler.cabal index 809b3bb2c..9aca5484d 100644 --- a/restyler.cabal +++ b/restyler.cabal @@ -1,13 +1,13 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.35.2. +-- This file has been generated from package.yaml by hpack version 0.36.0. -- -- see: https://github.com/sol/hpack -- --- hash: 96216864b988d5fa1f4bb2ecf7696ed5aa593345d8a946552299187955a0e9fe +-- hash: 8590878289ab72ae1d036e2be076c5254562a6d920c33640a3a6addb9382cb57 name: restyler -version: 0.2.0.0 +version: 0.2.1.0 license: MIT license-file: LICENSE build-type: Simple