-
Notifications
You must be signed in to change notification settings - Fork 0
Build and utilize pre-compiled binaries #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
6d65c67
Build and utilize pre-compiled binaries
pbrisbin 5b466dd
Add a "none" Job if all assets exist
pbrisbin 2e430b1
Update README.md
pbrisbin 693525b
Restyled by prettier-markdown
restyled-commits 706a476
Just see if windows works
pbrisbin 5c10e46
Try 7zip
pbrisbin 5526072
Use better extension for 7z
pbrisbin a2b6718
One more try?
pbrisbin be90483
We CAN make .zip files with 7z
pbrisbin 7d2a45c
We can do this
pbrisbin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
#!/usr/bin/env ruby | ||
require "json" | ||
|
||
RELEASE_NAME = "Binaries" | ||
|
||
EXISTING_ASSETS = JSON.parse(` | ||
gh --repo freckle/weeder-action release view #{RELEASE_NAME} --json assets | | ||
jq '.assets | map(.name)' | ||
`) | ||
|
||
GHCs = %W[ | ||
9.2.5 | ||
9.2.4 | ||
9.2.3 | ||
9.2.2 | ||
9.0.2 | ||
9.0.1 | ||
8.10.7 | ||
8.10.6 | ||
8.10.5 | ||
8.10.4 | ||
8.10.3 | ||
8.10.2 | ||
8.10.1 | ||
8.8.4 | ||
8.8.3 | ||
8.8.2 | ||
8.8.1 | ||
] | ||
|
||
Asset = Struct.new(:ghc, :os) do | ||
def name | ||
"weeder-#{ghc}-#{os}-x64.#{os_attributes.fetch(:ext)}" | ||
end | ||
|
||
def include | ||
{ asset: name, ghc: ghc, release: RELEASE_NAME }. | ||
merge(os_attributes). | ||
merge(version_attributes) | ||
end | ||
|
||
def os_attributes | ||
case os | ||
when "linux" | ||
{ runner: "ubuntu-latest", exe: "./weeder", ext: "tar.gz", zip: "tar -czf" } | ||
when "darwin" | ||
{ runner: "macOS-latest", exe: "./weeder", ext: "tar.gz", zip: "tar -czf" } | ||
when "win32" | ||
{ runner: "windows-latest", exe: "./weeder.exe", ext: "zip", zip: '"C:\Program Files\7-Zip\7z.exe" a -tzip' } | ||
else | ||
raise "Unexpected OS: #{os}, must be linux|darwin|win32" | ||
end | ||
end | ||
|
||
def version_attributes | ||
case ghc | ||
when /9\.2\..*/ | ||
{ | ||
version: "2.4.0", | ||
resolver: "lts-20.3", | ||
"extra-deps": "" | ||
} | ||
when /9\.0\..*/ | ||
{ | ||
version: "2.3.1", | ||
resolver: "lts-19.33", | ||
"extra-deps": "" | ||
} | ||
when /8\.10\..*/ | ||
{ | ||
version: "2.2.0", | ||
resolver: "lts-18.28", | ||
"extra-deps": [ | ||
"dhall-1.40.2", | ||
"generic-lens-2.2.1.0", | ||
"generic-lens-core-2.2.1.0" | ||
].join(",") | ||
} | ||
when /8\.8\..*/ | ||
{ | ||
version: "2.2.0", | ||
resolver: "lts-16.31", | ||
"extra-deps": [ | ||
"dhall-1.40.2", | ||
"generic-lens-2.2.1.0", | ||
"generic-lens-core-2.2.1.0", | ||
"base16-bytestring-1.0.2.0", | ||
"prettyprinter-1.7.1", | ||
"repline-0.4.2.0", | ||
"haskeline-0.8.2" | ||
].join(",") | ||
} | ||
end | ||
end | ||
|
||
def needed? | ||
!EXISTING_ASSETS.include?(name) | ||
end | ||
end | ||
|
||
def generate_matrix | ||
assets = %W[ linux darwin win32 ]. | ||
flat_map { |os| GHCs.map { |ghc| Asset.new(ghc, os) } }. | ||
filter(&:needed?) | ||
|
||
if assets.empty? | ||
{ | ||
asset: ["none"], | ||
include: [{ | ||
asset: "none", | ||
runner: "ubuntu-latest" | ||
}] | ||
} | ||
else | ||
{ | ||
asset: assets.map(&:name), | ||
include: assets.map(&:include) | ||
} | ||
end | ||
end | ||
|
||
puts JSON.dump(generate_matrix) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
name: Binaries | ||
|
||
on: | ||
pull_request: | ||
|
||
jobs: | ||
generate: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- id: generate | ||
run: | | ||
cat >>"$GITHUB_OUTPUT" <<EOM | ||
matrix<<EOJSON | ||
$(./.github/bin/build-binaries-matrix) | ||
EOJSON | ||
EOM | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
outputs: | ||
matrix: ${{ steps.generate.outputs.matrix }} | ||
|
||
binaries: | ||
needs: generate | ||
|
||
strategy: | ||
matrix: ${{ fromJSON(needs.generate.outputs.matrix) }} | ||
fail-fast: false | ||
|
||
runs-on: ${{ matrix.runner }} | ||
steps: | ||
- if: ${{ matrix.asset != 'none' }} | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/.stack | ||
./.stack-work | ||
key: ${{ runner.os }}-stack-${{ matrix.ghc }} | ||
restore-keys: | | ||
${{ runner.os }}-stack- | ||
|
||
- if: ${{ matrix.asset != 'none' }} | ||
shell: bash | ||
run: | | ||
cat >stack.yaml <<'EOM' | ||
resolver: ${{ matrix.resolver }} | ||
packages: [] | ||
extra-deps: [${{ matrix.extra-deps }}] | ||
EOM | ||
|
||
stack install weeder-${{ matrix.version }} --local-bin-path . | ||
|
||
${{ matrix.zip }} '${{ matrix.asset }}' ${{ matrix.exe }} | ||
gh --repo '${{ github.repository }}' release upload '${{ matrix.release }}' '${{ matrix.asset }}' | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,18 @@ | ||
name: Weeder | ||
description: Annotate unused functions in a Haskell project | ||
inputs: | ||
working-directory: | ||
description: Change to this directory before operating | ||
required: true | ||
default: . | ||
stack-yaml: | ||
description: Path to stack.yaml, relative to working-directory | ||
ghc-version: | ||
description: Full version of GHC your project uses (required) | ||
required: true | ||
default: stack.yaml | ||
weeder-version: | ||
description: Version of weeder to install (default latest) | ||
required: true | ||
default: "" | ||
weeder-arguments: | ||
description: | | ||
Arguments to pass when invoking weeder (default --require-hs-files) | ||
required: true | ||
default: --require-hs-files | ||
working-directory: | ||
description: Change to this directory before operating | ||
required: true | ||
default: . | ||
fail: | ||
description: Fail the build if unused functions found? (default true) | ||
required: true | ||
|
@@ -30,17 +25,11 @@ runs: | |
using: composite | ||
steps: | ||
- name: Install weeder | ||
shell: bash | ||
run: | | ||
if [[ -n "${{ inputs.weeder-version }}" ]]; then | ||
package=weeder-${{ inputs.weeder-version }} | ||
else | ||
package=weeder | ||
fi | ||
|
||
cd '${{ inputs.working-directory }}' | ||
stack --stack-yaml '${{ inputs.stack-yaml }}' install \ | ||
--copy-compiler-tool "$package" | ||
uses: pbrisbin/[email protected] | ||
with: | ||
name: weeder | ||
version: ${{ inputs.ghc-version }} | ||
url: "https://github.com/freckle/weeder-action/releases/download/Binaries/{name}-{version}-{os}-{arch}.{ext}" | ||
|
||
- id: weeder | ||
name: Run weeder | ||
|
@@ -54,8 +43,7 @@ runs: | |
|
||
cd '${{ inputs.working-directory }}' | ||
prefix=$(echo '${{ inputs.working-directory }}' | sed 's|/$||')/ | ||
stack --stack-yaml '${{ inputs.stack-yaml }}' exec -- \ | ||
weeder ${{ inputs.weeder-arguments }} | | ||
weeder ${{ inputs.weeder-arguments }} | | ||
sed "s|^|$prefix|; "'s/$/ is not used by any defined root/' | | ||
tee "$tmp" || true | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,3 @@ | ||
resolver: lts-18.16 | ||
extra-deps: | ||
- dhall-1.40.1@sha256:ecc984210717ae2785a02c31c8b10c23a854761dba60c09adf533459bf5fe9b6,35396 | ||
- generic-lens-2.2.0.0@sha256:4008a39f464e377130346e46062e2ac1211f9d2e256bbb1857216e889c7196be,3867 | ||
- generic-lens-core-2.2.0.0@sha256:b6b69e992f15fa80001de737f41f2123059011a1163d6c8941ce2e3ab44f8c03,2913 | ||
resolver: lts-20.3 | ||
ghc-options: | ||
"$locals": -fwrite-ide-info |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Side quest, would it make sense to contribute this matrix to
weeder
itself and pull binaries from that project?https://github.com/ocharles/weeder/releases
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ocharles is using
nix
, which makes binary caching easy, but I'm not sure the current state of multi GHC builds in that ecosystem.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was indeed surprised when I found they weren't there. It's possible needing to have a binary built against the GHC of your project was enough complexity that they punted -- or maybe there's an Actual Reason they'd not want it. I'll probably open an Issue to ask at some point.