Skip to content
This repository has been archived by the owner on Jul 9, 2024. It is now read-only.

chore(deps): update dependency @nordicsemiconductor/device-helpers to… #6872

chore(deps): update dependency @nordicsemiconductor/device-helpers to…

chore(deps): update dependency @nordicsemiconductor/device-helpers to… #6872

name: Test and Release
on:
workflow_dispatch:
push:
paths-ignore:
- Dockerfile
- .github/workflows/test-docker.yaml
- .github/workflows/publish-docker.yaml
- .github/workflows/cd.yaml
permissions:
id-token: write
contents: write
issues: write
jobs:
tests:
runs-on: ubuntu-22.04
# Running CI in clean environment is currently not possible: https://github.com/NordicSemiconductor/asset-tracker-cloud-azure-js/issues/1
environment:
name: ci
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
APP_NAME: ${{ secrets.APP_NAME }}
B2C_TENANT: ${{ secrets.B2C_TENANT }}
LOCATION: ${{ secrets.LOCATION }}
APP_REG_CLIENT_ID: ${{ secrets.APP_REG_CLIENT_ID }}
B2C_CLIENT_SECRET: ${{ secrets.B2C_CLIENT_SECRET }}
B2C_TENANT_ID: ${{ secrets.B2C_TENANT_ID }}
B2C_USER_FLOW_NAME: B2C_1_developer
RESOURCE_GROUP: ${{ secrets.RESOURCE_GROUP }}
MOCK_HTTP_API_STORAGE_ACCOUNT_NAME: mockhttpapi
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
steps:
- name: Print azure CLI version
uses: azure/CLI@v2
with:
inlineScript: az --version
- name: Login to Azure
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: List Azure accounts
uses: azure/CLI@v2
with:
inlineScript: |
az account list --output table
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20.x"
cache: "npm"
- name: Install dependencies
run: npm ci --no-audit
- run: npx tsc
- name: Check source code with eslint
run: npx eslint ./
- name: Check if source code is properly formatted
run: npx prettier -c ./
- name: Run Unit Tests
run: npm test
- name: Deploy Mock HTTP API
uses: azure/CLI@v2
with:
inlineScript: |
az deployment group create \
--resource-group ${RESOURCE_GROUP:-nrfassettrackerci} \
--mode Incremental \
--name test-mock-http-api-${{ github.sha }} \
--template-file mock-http-api.json \
--parameters \
storageAccountName=${MOCK_HTTP_API_STORAGE_ACCOUNT_NAME:-mockhttpapi}
- name: Determine Mock API endpoint
uses: azure/CLI@v2
with:
inlineScript: |
echo "MOCK_HTTP_API_ENDPOINT=`az functionapp show -g ${RESOURCE_GROUP:-nrfassettrackerci} -n ${MOCK_HTTP_API_STORAGE_ACCOUNT_NAME:-mockhttpapi}Functions | jq -r '.defaultHostName'`" >> $GITHUB_ENV
- name: Pack mock functions
run: node scripts/pack-mock-http-api-app.js
- name: Deploy mock functions
uses: azure/CLI@v2
with:
inlineScript: |
az functionapp deployment source config-zip -g ${RESOURCE_GROUP:-nrfassettrackerci} -n ${MOCK_HTTP_API_STORAGE_ACCOUNT_NAME:-mockhttpapi}Functions --src dist/mock-http-api.zip
- name: Set random nRF Cloud Team ID
run: |
echo "NRF_CLOUD_TEAM_ID=`uuidgen`" >> $GITHUB_ENV
- name: Set Key Vault name
run: |
echo "keyVaultName=${APP_NAME:-nrfassettrackerci}" >> $GITHUB_ENV
- name: Create nRF Cloud Location Services service key
run: openssl ecparam -name prime256v1 -genkey > nrfcloudservice.key
- name: Set secrets for nRF Cloud API
uses: azure/CLI@v2
with:
inlineScript: |
az keyvault secret set --vault-name ${keyVaultName} --name nrfCloudServiceKey --file nrfcloudservice.key
- name: Deploy solution
uses: azure/CLI@v2
with:
inlineScript: |
az deployment group create \
--resource-group ${RESOURCE_GROUP:-nrfassettrackerci} \
--mode Incremental \
--name test-${{ github.sha }} \
--template-file azuredeploy.json \
--parameters \
appName=${APP_NAME:-nrfassettrackerci} \
appRegistrationClientId=${APP_REG_CLIENT_ID} \
b2cTenant=${B2C_TENANT} \
b2cFlowName=B2C_1_developer \
nrfCloudTeamId=${NRF_CLOUD_TEAM_ID} \
nrfCloudApiEndpoint=https://${MOCK_HTTP_API_ENDPOINT}/api/api.nrfcloud.com/ \
keyVaultName=${keyVaultName}
- name: Pack functions
run: node scripts/pack-app.js
- name: Deploy Function App
uses: azure/CLI@v2
with:
inlineScript: |
az functionapp deployment source config-zip -g ${RESOURCE_GROUP:-nrfassettrackerci} -n ${APP_NAME:-nrfassettrackerci}api --src dist/functionapp.zip
- uses: actions/upload-artifact@v4
if: always()
with:
if-no-files-found: error
name: functionapp-${{ github.sha }}
path: dist/functionapp.zip
- name: Cache certificates
uses: actions/cache@v4
id: certs-cache
with:
path: ./certificates
key: certificates
- name: Create Intermediate CA certificate
if: steps.certs-cache.outputs.cache-hit != 'true'
run: |
./cli.sh create-ca-root
./cli.sh create-ca-intermediate
- name: Run End-to-End Tests
uses: nick-invision/retry@v2
env:
FORCE_COLOR: 3
with:
timeout_minutes: 10
max_attempts: 3
command: npm run test:e2e
- name: Delete device certificates
run: rm ./certificates/*/device-*
- name: Semantic release
if: success()
continue-on-error: true
run: npx semantic-release