-
Notifications
You must be signed in to change notification settings - Fork 161
141 lines (136 loc) · 4.07 KB
/
pr.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
name: Test PR
on:
pull_request:
paths:
- 'src/**'
- 'lib/**'
- '.github/workflows/pr.yaml'
jobs:
tests:
env:
RUSTC_WRAPPER: sccache
SCCACHE_CACHE_SIZE: 2G
SCCACHE_VERSION: 0.3.0
runs-on: ubuntu-latest
steps:
-
uses: actions/checkout@v3
-
name: Get changed files
id: files
uses: Ana06/[email protected]
with:
format: json
-
name: Process changed files
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
readarray -t TEMP <<< "$(jq -r '.[]' <<<'${{ steps.files.outputs.added_modified }}')"
for line in "${TEMP[@]}"
do
if [[ "$line" == *"src/rust"* ]]; then
echo "SETUP_RUST=true" >> $GITHUB_ENV
elif [[ "$line" == *"src/as"* ]]; then
echo "SETUP_AS=true" >> $GITHUB_ENV
fi
done
-
uses: google/wireit@setup-github-actions-caching/v1
if: ${{ env.SETUP_AS == 'true' }}
-
uses: actions/setup-node@v3
if: ${{ env.SETUP_AS == 'true' }}
with:
node-version: 16
cache: npm
cache-dependency-path: '**/package-lock.json'
-
name: Cache rust stuff
uses: actions/cache@v3
if: ${{ env.SETUP_RUST == 'true' }}
with:
path: |
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git/db
~/.cargo/bin
src/rust/**/target
key: ${{ runner.os }}-cargo3-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo3-
-
name: sccache
uses: actions/cache@v3
with:
path: ~/.cache/sccache
key: ${{ runner.os }}-sccache-${{ github.sha }}
restore-keys: ${{ runner.os }}-sccache-
-
uses: actions-rs/toolchain@v1
if: ${{ env.SETUP_RUST == 'true' }}
with:
toolchain: nightly
override: true
target: wasm32-unknown-unknown
-
name: Install build dependencies
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
sudo ln -s $(which wasm-ld-13 || which wasm-ld-12 || which wasm-ld-11 || which wasm-ld-10) /usr/bin/wasm-ld
AIDOKU_CLI_VER=$(gh api repos/Aidoku/aidoku-cli/releases -q '.[0].tag_name')
gh release download -R Aidoku/aidoku-cli "$AIDOKU_CLI_VER" -p *_amd64.deb
sudo dpkg -i "aidoku-cli_${AIDOKU_CLI_VER:1}_linux_amd64.deb"
SCCACHE_FILE=sccache-v$SCCACHE_VERSION-x86_64-unknown-linux-musl
curl -L https://github.com/mozilla/sccache/releases/download/v$SCCACHE_VERSION/$SCCACHE_FILE.tar.gz | tar -xz
sudo mv -f $SCCACHE_FILE/sccache* /usr/local/bin/sccache
sudo chmod +x /usr/local/bin/sccache
-
name: Build sources
id: build
run: |
REBUILD_C_SOURCES="false"
readarray -t TEMP <<< "$(jq -r '.[]' <<<'${{ steps.files.outputs.added_modified }}')"
while IFS= read -r -d $'\0' i; do
if [[ "$i" == *"src/rust"* ]]; then
(
cd "$i"
./build.sh -a
)
elif [[ "$i" == *"src/as"* ]]; then
(
cd "$i"
npm clean-install
npm run build
)
elif [[ "$i" == *"src/c"* ]]; then
(
cd "$i"
make CC="sccache clang" package.aix
)
elif [[ "$i" == *"lib/c" ]]; then
REBUILD_C_SOURCES="true"
fi
done < <(printf "%s\n" "${TEMP[@]}" | cut -d'/' -f-3 | sort -u | grep 'src' | tr '\n' '\0')
if [ "$REBUILD_C_SOURCES" = "true" ]; then
for src in ./src/c/*; do
(
cd "$src"
make package.aix
)
done
fi
-
name: Test if sources are valid
run: aidoku verify --force-color ./**/*.aix
-
name: Flatten packages directory
if: always()
run: aidoku build ./**/*.aix
-
uses: actions/upload-artifact@v3
if: always()
with:
name: packages
path: public/sources/*.aix
if-no-files-found: ignore