Skip to content

Commit

Permalink
Fix build on Azure (#1284)
Browse files Browse the repository at this point in the history
* Fix build on Azure

* Add debug statement

* Check azure before ci

* Remove log statements again

* Add test to verify correctness of alice pwd

* Try setting db connection in workflow

* Build azure as during github workflow

* Add logging to redis connection timeout
  • Loading branch information
tobiasdiez authored Aug 3, 2022
1 parent ff05d51 commit 4e0d526
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ jobs:
api_location: ".output/server" # Api source code path - optional
output_location: ".output/public" # Built app content directory - optional
###### End of Repository/Build Configurations ######
env:
DATABASE_URL: ${{ secrets.AZURE_TEST_DATABASE_URL }}

- name: Run API tests
run: yarn test:api --env-var='base_url=${{ steps.builddeploy.outputs.static_web_app_url }}/api'
Expand Down Expand Up @@ -121,8 +123,6 @@ jobs:
api_location: ".output/server" # Api source code path - optional
output_location: ".output/public" # Built app content directory - optional
###### End of Repository/Build Configurations ######
env:
NODE_ENV: "build"

- name: Run API tests
run: yarn test:api --env-var='base_url=${{ matrix.url }}/api'
Expand Down
4 changes: 4 additions & 0 deletions config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ function enumFromStringValue<T>(
}

function getEnvironment(): Environment {
if (process.env.INPUT_AZURE_STATIC_WEB_APPS_API_TOKEN) {
return Environment.AzureBuild
}

// Github always sets CI variable https://docs.github.com/en/actions/learn-github-actions/environment-variables
if (process.env.CI) {
return Environment.CI
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"dev": "nuxi dev",
"build": "nuxi build --fail-on-error",
"build:azure": "NITRO_PRESET=azure yarn build",
"build:azure": "INPUT_AZURE_STATIC_WEB_APPS_API_TOKEN=test NITRO_PRESET=azure yarn build",
"start": "nuxi preview",
"start:azure": "NUXT_PUBLIC_ENVIRONMENT=development npx @azure/static-web-apps-cli start .output/public --api-location .output/server",
"generate": "yarn prisma:generate && yarn graphql:generate",
Expand Down
9 changes: 9 additions & 0 deletions server/utils/crypto.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,13 @@ describe('verifyHash', () => {
const hashedPassword = await hash('password')
expect(await verifyHash('different', hashedPassword)).toBe(false)
})

it('returns true for the password of alice', async () => {
expect(
await verifyHash(
'EBNPXY35TYkYXHs',
'19184d8c1c1e9b483d8347f8da0d53ad92170233100d32c3a0d748725948c28d09a060d7f02962b7b93320c72a2cdd94f21b16b08bf8bd1cba0c5f77afeffddbb24df527c4f16f1fca6eb5480159b56df3d818b4b3c74ead04227a78b3d810b8'
)
).toBe(true)
})
})
8 changes: 7 additions & 1 deletion server/utils/services.factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,13 @@ export async function createRedisClient(): Promise<
delete redisConfig.password
}
const client = redis.createClient(redisConfig)
await client.connect()
try {
await client.connect()
} catch (exception) {
console.error('Error while connection to redis')
console.error(redisConfig)
throw exception
}
return client
}
}

0 comments on commit 4e0d526

Please sign in to comment.