Skip to content

Commit

Permalink
Merge 113ae2e into 241fb0d
Browse files Browse the repository at this point in the history
  • Loading branch information
pbrisbin authored Jul 22, 2024
2 parents 241fb0d + 113ae2e commit e48d917
Show file tree
Hide file tree
Showing 7 changed files with 139 additions and 118 deletions.
79 changes: 51 additions & 28 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,67 +11,70 @@ 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

image:
runs-on: ubuntu-latest
steps:
- id: meta
uses: docker/metadata-action@v3
uses: docker/metadata-action@v5
with:
images: restyled/restyler
tags: |
type=sha,prefix=,priority=1000
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 }}

Expand Down Expand Up @@ -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
2 changes: 2 additions & 0 deletions .hlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- ignore:
name: Functor law
83 changes: 0 additions & 83 deletions Makefile

This file was deleted.

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,23 @@ will be authored by your user.
## Development

```console
make
just
```

Requires [stack](https://docs.haskellstack.org/en/stable/README/).

## Tests

```console
make test
just test
```

### Integration

End-to-end test that restyles an example Pull Request:

```console
make test.integration
just test-integration
```

## `restyle-path`
Expand Down
79 changes: 79 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -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}}/*"
2 changes: 1 addition & 1 deletion package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: restyler
version: 0.2.0.0
version: 0.2.1.0
license: MIT

default-extensions:
Expand Down
6 changes: 3 additions & 3 deletions restyler.cabal
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit e48d917

Please sign in to comment.