1212 runs-on : ubuntu-latest
1313 steps :
1414 - uses : actions/checkout@v3
15- - uses : actions/setup-node@v3.5 .0
15+ - uses : actions/setup-node@v3.6 .0
1616 with :
17- node-version : " 16 "
17+ node-version : " 18 "
1818
1919 - name : Install system dependencies
2020 run : sudo apt update && sudo apt-get -y install libusb-1.0-0-dev libasound2-dev libudev-dev
4040 runs-on : ubuntu-latest
4141 steps :
4242 - uses : actions/checkout@v3
43- - uses : actions/setup-node@v3.5 .0
43+ - uses : actions/setup-node@v3.6 .0
4444 with :
45- node-version : " 16 "
45+ node-version : " 18 "
4646
4747 - name : Install system dependencies
4848 run : sudo apt update && sudo apt-get -y install libusb-1.0-0-dev libasound2-dev libudev-dev
6464 os : [ubuntu-latest, windows-2019]
6565 runs-on : ${{ matrix.os }}
6666 steps :
67- - uses : actions/setup-node@v3.5 .0
67+ - uses : actions/setup-node@v3.6 .0
6868 with :
69- node-version : " 16 "
69+ node-version : " 18 "
7070
7171 - name : Download NodeCG
7272 uses : actions/checkout@v3
@@ -76,19 +76,31 @@ jobs:
7676 - name : Get NodeCG commit hash
7777 id : nodecgHash
7878 shell : bash
79- run : echo "::set-output name=nodecgHash:: $(git rev-parse HEAD)"
79+ run : echo "NODECG_HASH= $(git rev-parse HEAD)" >> $GITHUB_ENV
8080
8181 - name : Cache NodeCG dependencies
82- id : cache-nodecg
82+ id : cache-nodecg-deps
8383 uses : actions/cache@v3
8484 with :
8585 path : ' node_modules'
86- key : ${{ runner.os }}-${{ steps.nodecgHash.outputs.nodecgHash }}-nodecg
86+ key : ${{ runner.os }}-${{ env.NODECG_HASH }}-nodecg-deps
87+
88+ - name : Cache NodeCG compilation outputs
89+ id : cache-nodecg-build
90+ uses : actions/cache@v3
91+ with :
92+ path : ' build'
93+ key : ${{ runner.os }}-${{ env.NODECG_HASH }}-nodecg-build
8794
8895 - name : Install NodeCG dependencies
8996 # Only get dependencies if we didn't get them from the cache
90- if : steps.cache-nodecg.outputs.cache-hit != 'true'
91- run : npm install --prod
97+ if : steps.cache-nodecg-deps.outputs.cache-hit != 'true'
98+ run : npm install
99+
100+ - name : Build NodeCG
101+ # Only build NodeCG if we didn't have cached compilation results
102+ if : steps.cache-nodecg-build.outputs.cache-hit != 'true'
103+ run : npm run build
92104
93105 - name : Setup NodeCG config linux
94106 if : matrix.os == 'ubuntu-latest'
@@ -124,7 +136,19 @@ jobs:
124136 run : npm run build
125137 working-directory : ./nodecg-io
126138
127- - name : Run test
139+ # Under linux we need to run the test as the root user because
140+ # the midi service requires access to audio devices.
141+ # By default the GitHub Actions user is not in the `audio` group and therefore
142+ # has no access. Either we need to run as root to get access or need to add the user
143+ # to the `audio` group which doesn't work for us, as it would only take affect on next login,
144+ # but we cannot logout and login in CI.
145+ - name : Run test (ubuntu)
146+ if : matrix.os == 'ubuntu-latest'
147+ run : sudo node .scripts/ci-nodecg-integration.mjs
148+ working-directory : ./nodecg-io
149+
150+ - name : Run test (windows)
151+ if : matrix.os == 'windows-2019'
128152 shell : bash
129153 run : node .scripts/ci-nodecg-integration.mjs
130154 working-directory : ./nodecg-io
@@ -142,9 +166,9 @@ jobs:
142166 - nodecg
143167 steps :
144168 - uses : actions/checkout@v3
145- - uses : actions/setup-node@v3.5 .0
169+ - uses : actions/setup-node@v3.6 .0
146170 with :
147- node-version : " 16 "
171+ node-version : " 18 "
148172
149173 - name : Download compilation results # From the build step
150174 uses : actions/download-artifact@v3
@@ -154,6 +178,22 @@ jobs:
154178 - name : Extract compilation results
155179 run : tar xvf compilation-results.tar.gz
156180
181+ # All twitch services depend on the utility package `nodecg-io-twitch-auth`.
182+ # In the repository the services depend on the latest development version which is not yet published.
183+ # If someone installs the service using the published tarball npm would try to get the
184+ # unpublished version of twitch-auth from the npm registry which is not possible.
185+ # To fix this we update the version of the twitch-auth package in all usages
186+ # to also reference the published tarball.
187+ - name : Patch twitch-auth dependency to use published current tarball
188+ run : |
189+ # Get current version as it is needed for the tarball file name
190+ TWITCH_AUTH_VERSION=$(cat utils/nodecg-io-twitch-auth/package.json | jq .version -r)
191+
192+ # Find usages in all package.json files and replace with the corresponding tarball url
193+ find . -name 'package.json' -exec grep -q -E '"nodecg-io-twitch-auth": ".+"' {} \; -print # Print found files for debug purposes
194+ find . -name 'package.json' -exec grep -q -E '"nodecg-io-twitch-auth": ".+"' {} \; -print0 | \
195+ xargs -0 sed -i "s/\"nodecg-io-twitch-auth\": \".*\"/\"nodecg-io-twitch-auth\": \"https:\/\/codeoverflow-org.github.io\/nodecg-io-publish\/nodecg-io-twitch-auth-${TWITCH_AUTH_VERSION}.tgz\"/g"
196+
157197 - name : Create npm tarballs
158198 run : npm pack --workspaces
159199
0 commit comments