2023-07-13 11:44:05 +00:00
name : Release
2023-10-13 09:24:42 +00:00
run-name : Testing and Releasing DC
2023-07-13 11:44:05 +00:00
on :
push :
branches :
- main
jobs :
2023-10-13 09:24:42 +00:00
Build-production-and-ng-test :
runs-on : ubuntu-latest
steps :
- uses : actions/checkout@v3
2024-05-30 12:46:10 +00:00
- uses : actions/setup-node@v4
2023-10-13 09:24:42 +00:00
with :
2024-05-30 12:56:55 +00:00
node-version : 20.14 .0
2023-10-13 09:24:42 +00:00
- name : Write .npmrc file
run : |
touch client/.npmrc
echo '${{ secrets.NPMRC}}' > client/.npmrc
- name : Install Chrome for Angular tests
run : |
apt-get update
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
apt install -y ./google-chrome*.deb;
export CHROME_BIN=/usr/bin/google-chrome
- name : Write cypress credentials
run : echo "$CYPRESS_CREDS" > ./client/cypress.env.json
shell : bash
env :
CYPRESS_CREDS : ${{ secrets.CYPRESS_CREDS }}
- name : Install dependencies
2024-04-01 09:14:00 +00:00
run : |
cd client
2024-05-02 08:04:31 +00:00
# Decrypt and Install sheet
echo ${{ secrets.SHEET_PWD }} | gpg --batch --yes --passphrase-fd 0 ./libraries/sheet-crypto.tgz.gpg
2024-05-30 13:57:18 +00:00
npm ci
2023-10-13 09:24:42 +00:00
- name : Check audit
# Audit should fail and stop the CI if critical vulnerability found
run : |
npm audit --audit-level=critical --omit=dev
cd ./sas
npm audit --audit-level=critical --omit=dev
cd ../client
npm audit --audit-level=critical --omit=dev
- name : Angular Tests
run : |
cd client
2024-04-12 12:23:04 +00:00
npm run test:headless
2023-10-13 09:24:42 +00:00
- name : Angular Production Build
run : |
cd client
npm run postinstall
npm run build
Build-and-test-development :
runs-on : ubuntu-latest
needs : Build-production-and-ng-test
steps :
- uses : actions/checkout@v3
2024-05-30 12:46:10 +00:00
- uses : actions/setup-node@v4
2023-10-13 09:24:42 +00:00
with :
2024-05-30 12:56:55 +00:00
node-version : 20.14 .0
2023-10-13 09:24:42 +00:00
- name : Write .npmrc file
run : |
touch client/.npmrc
echo '${{ secrets.NPMRC}}' > client/.npmrc
- run : apt-get update
- run : wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
- run : apt install -y ./google-chrome*.deb;
- run : export CHROME_BIN=/usr/bin/google-chrome
- run : apt-get update -y
- run : apt-get -y install libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 libxtst6 xauth xvfb
- run : apt -y install jq
- name : Write cypress credentials
run : echo "$CYPRESS_CREDS" > ./client/cypress.env.json
shell : bash
env :
CYPRESS_CREDS : ${{ secrets.CYPRESS_CREDS }}
- name : Install dependencies
2024-04-01 09:14:00 +00:00
run : |
cd client
2024-05-02 08:04:31 +00:00
# Decrypt and Install sheet
echo ${{ secrets.SHEET_PWD }} | gpg --batch --yes --passphrase-fd 0 ./libraries/sheet-crypto.tgz.gpg
2024-05-30 13:57:18 +00:00
npm ci
2023-10-13 09:24:42 +00:00
# Install pm2 and prepare SASJS server
- run : npm i -g pm2
- run : curl -L https://github.com/sasjs/server/releases/latest/download/linux.zip > linux.zip
- run : unzip linux.zip
- run : touch .env
- run : echo RUN_TIMES=js >> .env
- run : echo NODE_PATH=node >> .env
- run : echo CORS=enable >> .env
- run : echo WHITELIST=http://localhost:4200 >> .env
- run : cat .env
- run : pm2 start api-linux --wait-ready
- name : Deploy mocked services
run : |
cd ./sas/mocks/sasjs
npm install -g @sasjs/cli
npm install -g replace-in-files-cli
sasjs cbd -t server-ci
# sasjs request services/admin/makedata -t server-ci -d ./deploy/makeData4GL.json -c ./deploy/requestConfig.json -o ./output.json
- name : Install ZIP
run : |
apt-get update
apt-get install zip
- name : Prepare and run frontend and cypress
run : |
cd ./client
mv ./cypress.env.example.json ./cypress.env.json
replace-in-files --regex='"username".*' --replacement='"username":"'${{ secrets.CYPRESS_USERNAME_SASJS }}'",' ./cypress.env.json
replace-in-files --regex='"password".*' --replacement='"password":"'${{ secrets.CYPRESS_PWD_SASJS }}'" ' ./cypress.env.json
cat ./cypress.env.json
npm run postinstall
# Prepare index.html to SASJS local
replace-in-files --regex='serverUrl=".*?"' --replacement='serverUrl="http://localhost:5000"' ./src/index.html
replace-in-files --regex='appLoc=".*?"' --replacement='appLoc="/Public/app/devtest"' ./src/index.html
replace-in-files --regex='serverType=".*?"' --replacement='serverType="SASJS"' ./src/index.html
replace-in-files --regex='"hosturl".*' --replacement='hosturl:"http://localhost:4200",' ./cypress.config.ts
cat ./cypress.config.ts
# Start frontend and run cypress
npm start & npx wait-on http://localhost:4200 && npx cypress run --browser chrome --spec "cypress/e2e/liveness.cy.ts,cypress/e2e/editor.cy.ts,cypress/e2e/excel.cy.ts,cypress/e2e/filtering.cy.ts,cypress/e2e/licensing.cy.ts"
- name : Zip Cypress videos
if : always()
run : |
zip -r cypress-videos ./client/cypress/videos
2023-10-16 14:11:56 +00:00
- name : Add cypress videos artifacts
if : always()
2023-10-13 09:24:42 +00:00
uses : actions/upload-artifact@v3
with :
name : cypress-videos.zip
path : cypress-videos.zip
2023-07-13 11:44:05 +00:00
release :
runs-on : ubuntu-latest
2023-10-13 09:24:42 +00:00
needs : [ Build-production-and-ng-test, Build-and-test-development]
2023-07-13 11:44:05 +00:00
steps :
- uses : actions/checkout@v3
2024-05-30 12:46:10 +00:00
- uses : actions/setup-node@v4
2023-07-13 11:44:05 +00:00
with :
2024-05-30 12:56:55 +00:00
node-version : 20.14 .0
2023-07-13 11:44:05 +00:00
- name : Write .npmrc file
run : |
echo "$NPMRC" > client/.npmrc
echo "legacy-peer-deps=true" >> client/.npmrc
shell : bash
env :
NPMRC : ${{ secrets.NPMRC}}
2023-07-25 20:36:10 +00:00
- name : Install packages
2023-07-13 11:44:05 +00:00
run : |
apt-get update
2023-07-25 13:45:11 +00:00
apt-get install zip -y
2023-07-25 20:36:10 +00:00
# sasjs cli is used to compile & build the SAS services
2023-07-25 09:34:58 +00:00
npm i -g @sasjs/cli
2023-07-25 20:36:10 +00:00
# jq is used to parse the release JSON
2023-07-25 13:45:11 +00:00
apt-get install jq -y
2023-12-04 13:44:49 +00:00
# doxygen is used for the SASJS docs
apt-get update
2023-12-04 16:06:18 +00:00
apt-get install doxygen -y
2023-07-13 11:44:05 +00:00
2024-05-02 16:41:25 +00:00
- name : Frontend Preliminary Build
description : We want to prevent creating empty release if frontend fails
run : |
cd client
# Decrypt and Install sheet
echo ${{ secrets.SHEET_PWD }} | gpg --batch --yes --passphrase-fd 0 ./libraries/sheet-crypto.tgz.gpg
2024-05-30 13:57:18 +00:00
npm ci
2024-05-03 07:03:56 +00:00
npm i webpack
2024-05-02 16:41:25 +00:00
npm run build
2023-07-25 20:36:10 +00:00
- name : Create Empty Release (assets are posted later)
2023-07-13 11:44:05 +00:00
run : |
npm i
npm i -g semantic-release
2023-10-11 14:34:06 +00:00
# We do a semantic-release DRY RUN to make the job fail if there are no changes to release
GITEA_TOKEN=${{ secrets.RELEASE_TOKEN }} GITEA_URL=https://git.datacontroller.io semantic-release --dry-run | grep -q "There are no relevant changes, so no new version is released." && exit 1
2023-07-25 09:34:58 +00:00
GITEA_TOKEN=${{ secrets.RELEASE_TOKEN }} GITEA_URL=https://git.datacontroller.io semantic-release
2023-07-13 11:44:05 +00:00
2023-07-25 13:45:11 +00:00
- name : Frontend Build
2023-07-25 20:36:10 +00:00
description : Must be created AFTER the release as the version (git tag) is used in the interface
2023-07-25 13:45:11 +00:00
run : |
cd client
npm run build
2023-07-25 09:34:58 +00:00
- name : Build SAS9 EBI Release
2023-07-25 20:36:10 +00:00
description : Compile SAS 9 services, remove tests & create deployment program
2023-07-13 11:44:05 +00:00
run : |
2023-07-25 09:34:58 +00:00
cd sas
2023-10-09 09:00:09 +00:00
npm i
2023-07-25 09:34:58 +00:00
sasjs c -t sas9
rm -rf sasjsbuild/tests
sasjs b -t sas9
cp sasjsbuild/mysas9deploy.sas ./demostream_sas9.sas
#
# remove streamed component and rebuild SAS 9 services
#
rm -rf sasjsbuild/services/web9
rm sasjsbuild/services/clickme.sas
sasjs b -t sas9
cp sasjsbuild/mysas9deploy.sas ./sas9.sas
- name : Build SASjs Server Release
2023-07-25 20:36:10 +00:00
description : Compile Base (SASjs) services, remove tests & create deployment JSON
2023-07-25 09:34:58 +00:00
run : |
cd sas
cp sasjs/utils/favicon.ico ../client/dist/favicon.ico
sasjs c -t server
rm -rf sasjsbuild/tests
sasjs b -t server
cp sasjsbuild/server.json.zip ./sasjs_server.json.zip
- name : Build Viya Release
description : compile Viya Streaming Deploy (without tests)
run : |
cd sas
sasjs c -t viya
rm -rf sasjsbuild/tests
sed -i -e 's/servertype="SASJS"/servertype="SASVIYA"/g' sasjsbuild/services/clickme.html
sasjs b -t viya
cp sasjsbuild/viya.sas ./demostream_viya.sas
# compile Viya Full deploy (without web)
rm -rf sasjsbuild/services/web
rm sasjsbuild/services/clickme.html
sasjs b -t viya
cp sasjsbuild/viya.sas ./viya.sas
2024-05-06 07:04:19 +00:00
cp sasjsbuild/viya.json ./viya.json
2023-07-25 09:34:58 +00:00
- name : Zip Frontend (including viya.json for full viya deploy)
run : |
cd sas
cp sasjsbuild/viya.json ../client/dist
cd ..
zip -r frontend.zip ./client/dist
2023-07-13 11:44:05 +00:00
- name : Release Typedoc
run : |
cd client
2023-08-24 09:44:54 +00:00
npm -g install cloudron-surfer
2023-08-01 12:50:04 +00:00
npm run compodoc:build
2023-08-02 07:24:16 +00:00
surfer put --token ${{ secrets.TSDOC_TOKEN }} --server webdoc.datacontroller.io documentation/* /
2023-07-25 09:34:58 +00:00
2023-11-14 22:23:05 +00:00
- name : Release code.datacontroller.io
run : |
cd sas
sasjs doc
surfer put --token ${{ secrets.CODE_DATACONTROLLER_IO }} --server code.datacontroller.io sasjsbuild/sasdocs/* /
2023-07-25 13:45:11 +00:00
- name : Upload assets to release
2023-07-25 09:34:58 +00:00
run : |
2023-07-25 13:45:11 +00:00
RELEASE_ID=`curl -k 'https://git.datacontroller.io/api/v1/repos/dc/dc/releases/latest?access_token=${{ secrets.RELEASE_TOKEN }}' | jq -r '.id'`
2023-07-26 11:39:04 +00:00
RELEASE_BODY=`curl -k 'https://git.datacontroller.io/api/v1/repos/dc/dc/releases/latest?access_token=${{ secrets.RELEASE_TOKEN }}' | jq -r '.body'`
# Update body
2023-10-09 10:46:17 +00:00
curl --data '{"draft": false,"body":"'"$RELEASE_BODY\n\nFor installation instructions, please visit https://docs.datacontroller.io/"'"}' -X PATCH --header 'Content-Type: application/json' -k https://git.datacontroller.io/api/v1/repos/dc/dc/releases/$RELEASE_ID?access_token=${{ secrets.RELEASE_TOKEN }}
2023-07-26 11:39:04 +00:00
# Upload assets
2023-07-25 13:45:11 +00:00
URL="https://git.datacontroller.io/api/v1/repos/dc/dc/releases/$RELEASE_ID/assets?access_token=${{ secrets.RELEASE_TOKEN }}"
curl -k $URL -F attachment=@frontend.zip
curl -k $URL -F attachment=@sas/demostream_sas9.sas
curl -k $URL -F attachment=@sas/demostream_viya.sas
curl -k $URL -F attachment=@sas/sasjs_server.json.zip
curl -k $URL -F attachment=@sas/sas9.sas
curl -k $URL -F attachment=@sas/viya.sas
2024-05-06 07:04:19 +00:00
curl -k $URL -F attachment=@sas/viya.json