|
1 | | -# name: Build and Test |
| 1 | +name: Build and Test |
2 | 2 |
|
3 | | -# on: |
4 | | -# workflow_call: |
5 | | -# inputs: |
6 | | -# platform: |
7 | | -# required: true |
8 | | -# description: 'build platform' |
9 | | -# type: string |
10 | | -# target-platform: |
11 | | -# required: true |
12 | | -# description: 'target platform' |
13 | | -# type: string |
14 | | -# compiler-nix-name: |
15 | | -# required: true |
16 | | -# description: 'compiler name in nix format. e.g. ghc96' |
17 | | -# type: string |
18 | | -# minimal: |
19 | | -# description: 'without hls, hlint, ...' |
20 | | -# type: boolean |
21 | | -# default: true |
22 | | -# iog: |
23 | | -# description: 'without iog libs: libsodium, libsecp256k1, libblst, ...' |
24 | | -# type: boolean |
25 | | -# default: false |
26 | | -# package: |
27 | | -# description: 'name of hackage package' |
28 | | -# type: string |
29 | | -# default: hello |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + platform: |
| 7 | + required: true |
| 8 | + description: 'build platform' |
| 9 | + type: string |
| 10 | + target-platform: |
| 11 | + required: true |
| 12 | + description: 'target platform' |
| 13 | + type: string |
| 14 | + compiler-nix-name: |
| 15 | + required: true |
| 16 | + description: 'compiler name in nix format. e.g. ghc96' |
| 17 | + type: string |
| 18 | + minimal: |
| 19 | + description: 'without hls, hlint, ...' |
| 20 | + type: boolean |
| 21 | + default: true |
| 22 | + iog: |
| 23 | + description: 'without iog libs: libsodium, libsecp256k1, libblst, ...' |
| 24 | + type: boolean |
| 25 | + default: false |
| 26 | + package: |
| 27 | + description: 'name of hackage package' |
| 28 | + type: string |
| 29 | + default: hello |
30 | 30 |
|
31 | | -# jobs: |
32 | | -# build: |
33 | | -# name: Build ${{ inputs.package }} executable |
34 | | -# defaults: |
35 | | -# run: |
36 | | -# shell: devx {0} |
37 | | -# runs-on: ${{ inputs.platform == 'x86_64-linux' && 'ubuntu-latest' || 'macos-latest' }} |
38 | | -# steps: |
39 | | -# - name: Checkout code |
40 | | -# uses: actions/checkout@v4 |
41 | | -# - name: Install GHC and Cabal |
42 | | -# uses: input-output-hk/actions/devx@latest |
43 | | -# with: |
44 | | -# platform: ${{ inputs.platform }} |
45 | | -# target-platform: ${{ inputs.target-platform }} |
46 | | -# compiler-nix-name: ${{ inputs.compiler-nix-name }} |
47 | | -# minimal: ${{ inputs.minimal }} |
48 | | -# iog: ${{ inputs.iog }} |
49 | | -# - name: cabal update |
50 | | -# run: cabal update |
51 | | -# - name: unapck hello |
52 | | -# run: cabal unpack hello |
53 | | -# - name: build hello |
54 | | -# working-directory: hello-1.0.0.2 |
55 | | -# run: | |
56 | | -# cabal build${{ inputs.target-platform == '-static' && ' --enable-executable-static' || '' }} |
57 | | -# mkdir bin |
58 | | -# cp dist-newstyle/build/*/*/hello-1.0.0.2/build/hello/hello${{ inputs.target-platform == '-windows' && '.exe' || '' }} bin |
59 | | -# ls -lah bin/ |
60 | | -# - name: Fix up the nix dependencies |
61 | | -# working-directory: hello-1.0.0.2 |
62 | | -# if: (inputs.platform == 'x86_64-darwin' || inputs.platform == 'aarch64-darwin') && inputs.target-platform == '' |
63 | | -# run: fixup-nix-deps bin/hello |
| 31 | +jobs: |
| 32 | + build: |
| 33 | + name: Build ${{ inputs.package }} executable |
| 34 | + defaults: |
| 35 | + run: |
| 36 | + shell: devx {0} |
| 37 | + runs-on: ${{ inputs.platform == 'x86_64-linux' && 'ubuntu-latest' || 'macos-latest' }} |
| 38 | + steps: |
| 39 | + - name: Checkout code |
| 40 | + uses: actions/checkout@v4 |
| 41 | + - name: Install GHC and Cabal |
| 42 | + uses: input-output-hk/actions/devx@latest |
| 43 | + with: |
| 44 | + platform: ${{ inputs.platform }} |
| 45 | + target-platform: ${{ inputs.target-platform }} |
| 46 | + compiler-nix-name: ${{ inputs.compiler-nix-name }} |
| 47 | + minimal: ${{ inputs.minimal }} |
| 48 | + iog: ${{ inputs.iog }} |
| 49 | + - name: cabal update |
| 50 | + run: cabal update |
| 51 | + - name: unapck hello |
| 52 | + run: cabal unpack hello |
| 53 | + - name: build hello |
| 54 | + working-directory: hello-1.0.0.2 |
| 55 | + run: | |
| 56 | + cabal build${{ inputs.target-platform == '-static' && ' --enable-executable-static' || '' }} |
| 57 | + mkdir bin |
| 58 | + cp dist-newstyle/build/*/*/hello-1.0.0.2/build/hello/hello${{ inputs.target-platform == '-windows' && '.exe' || '' }} bin |
| 59 | + ls -lah bin/ |
| 60 | + - name: Fix up the nix dependencies |
| 61 | + working-directory: hello-1.0.0.2 |
| 62 | + if: (inputs.platform == 'x86_64-darwin' || inputs.platform == 'aarch64-darwin') && inputs.target-platform == '' |
| 63 | + run: fixup-nix-deps bin/hello |
64 | 64 |
|
65 | | -# - name: Inspect and patchup dynamic build product |
66 | | -# working-directory: hello-1.0.0.2 |
67 | | -# if: ${{ inputs.platform == 'x86_64-linux' && inputs.target-platform == '' }} |
68 | | -# run: | |
69 | | -# nix-shell -p patchelf --run 'patchelf --print-interpreter bin/hello' |
70 | | -# nix-shell -p patchelf --run 'patchelf --print-needed bin/hello' |
71 | | -# # setting the interpreter to the 64bit ubuntu one. |
72 | | -# nix-shell -p patchelf --run 'patchelf --set-interpreter /lib64/ld-linux-x86-64.so.2 bin/hello' |
73 | | -# # this will copy _all_ dependent libraries. This might not be the |
74 | | -# # greatest idea. But it's most likely the most reliable. |
75 | | -# nix-shell -p patchelf --run 'mkdir -p bin/libs |
76 | | -# for lib in $(patchelf --print-needed bin/hello); do |
77 | | -# for path in $(patchelf --print-rpath bin/hello|tr : \ ); do |
78 | | -# if [ -f "$path/$lib" ]; then |
79 | | -# cp "$path/$lib" bin/libs/ |
80 | | -# if patchelf --print-interpreter "bin/libs/$lib" >/dev/null 2>&1; then |
81 | | -# patchelf --set-interpreter /lib/ld-linux.so.2 "bin/libs/$lib" |
82 | | -# fi |
83 | | -# break |
84 | | -# fi |
85 | | -# done |
86 | | -# done' |
87 | | -# # we set /lib64 as well, even though we likely shouldn't need that, as all |
88 | | -# # libraries are found in the libs folder we ship along. |
89 | | -# nix-shell -p patchelf --run 'patchelf --set-rpath \$ORIGIN/lib:/lib64 bin/hello' |
| 65 | + - name: Inspect and patchup dynamic build product |
| 66 | + working-directory: hello-1.0.0.2 |
| 67 | + if: ${{ inputs.platform == 'x86_64-linux' && inputs.target-platform == '' }} |
| 68 | + run: | |
| 69 | + nix-shell -p patchelf --run 'patchelf --print-interpreter bin/hello' |
| 70 | + nix-shell -p patchelf --run 'patchelf --print-needed bin/hello' |
| 71 | + # setting the interpreter to the 64bit ubuntu one. |
| 72 | + nix-shell -p patchelf --run 'patchelf --set-interpreter /lib64/ld-linux-x86-64.so.2 bin/hello' |
| 73 | + # this will copy _all_ dependent libraries. This might not be the |
| 74 | + # greatest idea. But it's most likely the most reliable. |
| 75 | + nix-shell -p patchelf --run 'mkdir -p bin/libs |
| 76 | + for lib in $(patchelf --print-needed bin/hello); do |
| 77 | + for path in $(patchelf --print-rpath bin/hello|tr : \ ); do |
| 78 | + if [ -f "$path/$lib" ]; then |
| 79 | + cp "$path/$lib" bin/libs/ |
| 80 | + if patchelf --print-interpreter "bin/libs/$lib" >/dev/null 2>&1; then |
| 81 | + patchelf --set-interpreter /lib/ld-linux.so.2 "bin/libs/$lib" |
| 82 | + fi |
| 83 | + break |
| 84 | + fi |
| 85 | + done |
| 86 | + done' |
| 87 | + # we set /lib64 as well, even though we likely shouldn't need that, as all |
| 88 | + # libraries are found in the libs folder we ship along. |
| 89 | + nix-shell -p patchelf --run 'patchelf --set-rpath \$ORIGIN/lib:/lib64 bin/hello' |
90 | 90 |
|
91 | | -# - name: Upload hello executable |
92 | | -# uses: actions/upload-artifact@v4 |
93 | | -# with: |
94 | | -# overwrite: true |
95 | | -# name: ${{ inputs.package }}-${{ inputs.platform }}${{ inputs.target-platform }}-${{ inputs.compiler-nix-name }}${{ inputs.minimal && '-minimal' || '' }}${{ inputs.iog && '-iog' || '' }} |
96 | | -# path: | |
97 | | -# hello-1.0.0.2/bin/hello${{ inputs.target-platform == '-windows' && '.exe' || '' }} |
98 | | -# hello-1.0.0.2/bin/libs |
| 91 | + - name: Upload hello executable |
| 92 | + uses: actions/upload-artifact@v4 |
| 93 | + with: |
| 94 | + overwrite: true |
| 95 | + name: ${{ inputs.package }}-${{ inputs.platform }}${{ inputs.target-platform }}-${{ inputs.compiler-nix-name }}${{ inputs.minimal && '-minimal' || '' }}${{ inputs.iog && '-iog' || '' }} |
| 96 | + path: | |
| 97 | + hello-1.0.0.2/bin/hello${{ inputs.target-platform == '-windows' && '.exe' || '' }} |
| 98 | + hello-1.0.0.2/bin/libs |
99 | 99 |
|
100 | | -# run: |
101 | | -# name: Run ${{ inputs.package }} executable |
102 | | -# needs: build |
| 100 | + run: |
| 101 | + name: Run ${{ inputs.package }} executable |
| 102 | + needs: build |
103 | 103 |
|
104 | | -# runs-on: ${{ inputs.target-platform == '-windows' && 'windows-latest' || (inputs.platform == 'x86_64-linux' && 'ubuntu-latest' || 'macos-latest') }} |
105 | | -# steps: |
106 | | -# - name: Download hello executable |
107 | | -# uses: actions/download-artifact@v4 |
108 | | -# with: |
109 | | -# name: ${{ inputs.package }}-${{ inputs.platform }}${{ inputs.target-platform }}-${{ inputs.compiler-nix-name }}${{ inputs.minimal && '-minimal' || '' }}${{ inputs.iog && '-iog' || '' }} |
| 104 | + runs-on: ${{ inputs.target-platform == '-windows' && 'windows-latest' || (inputs.platform == 'x86_64-linux' && 'ubuntu-latest' || 'macos-latest') }} |
| 105 | + steps: |
| 106 | + - name: Download hello executable |
| 107 | + uses: actions/download-artifact@v4 |
| 108 | + with: |
| 109 | + name: ${{ inputs.package }}-${{ inputs.platform }}${{ inputs.target-platform }}-${{ inputs.compiler-nix-name }}${{ inputs.minimal && '-minimal' || '' }}${{ inputs.iog && '-iog' || '' }} |
110 | 110 |
|
111 | | -# # see https://github.com/actions/upload-artifact#permission-loss |
112 | | -# # windows doesn't care \o/ |
113 | | -# - name: Restore Executable Permission |
114 | | -# if: ${{ inputs.target-platform != '-windows' }} |
115 | | -# run: chmod +x ./hello |
| 111 | + # see https://github.com/actions/upload-artifact#permission-loss |
| 112 | + # windows doesn't care \o/ |
| 113 | + - name: Restore Executable Permission |
| 114 | + if: ${{ inputs.target-platform != '-windows' }} |
| 115 | + run: chmod +x ./hello |
116 | 116 |
|
117 | | -# - name: Run hello executable |
118 | | -# run: ./hello |
| 117 | + - name: Run hello executable |
| 118 | + run: ./hello |
0 commit comments