Skip to content

Commit

Permalink
Merge branch 'main' into ci/run-ci-on-release
Browse files Browse the repository at this point in the history
  • Loading branch information
TheUnderScorer authored Nov 29, 2023
2 parents 8046088 + bad941f commit 29761e5
Show file tree
Hide file tree
Showing 8 changed files with 140 additions and 3 deletions.
1 change: 0 additions & 1 deletion .github/workflows/create-pr-to-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
release:
types:
- published
- prereleased

permissions:
pull-requests: write
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: release
on:
workflow_dispatch:
push:
branches:
- main
Expand Down
69 changes: 69 additions & 0 deletions azure-pipelines-rc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
pr: none
trigger:
tags:
include:
- 'v*'

pool:
vmImage: ubuntu-latest

variables:
TAG: $[replace(variables['Build.SourceBranch'], 'refs/tags/', '')]

steps:
- script: echo $TAG
displayName: 'Output tag'
env:
TAG: $(TAG)
- script: yarn install --ignore-engines && npx playwright install && yarn global add ts-node
displayName: 'Install dependencies'
- script: ts-node scripts/downloadGithubReleasePackage.ts
displayName: 'Download release artifact from GitHub'
env:
TAG: $(TAG)
- script: yarn build:example-website
displayName: 'Build website'
env:
VITE_API_KEY: $(API_KEY)
VITE_ENDPOINT: $(VITE_ENDPOINT)
VITE_SCRIPT_URL_PATTERN: $(VITE_SCRIPT_URL_PATTERN)
NODE_OPTIONS: "--max_old_space_size=16384"

- task: AzureCLI@2
displayName: 'Deploy infrastructure'
env:
AZURE_STORAGE_ACCOUNT_NAME: $(AZURE_STORAGE_ACCOUNT_NAME)
AZURE_STORAGE_CONTAINER_NAME: $(AZURE_STORAGE_CONTAINER_NAME)
AZURE_STORAGE_RESOURCE_GROUP: $(AZURE_STORAGE_RESOURCE_GROUP)
AZURE_SUBSCRIPTION_ID: $(AZURE_SUBSCRIPTION_ID)
FPJS_PRE_SHARED_SECRET: $(FPJS_PRE_SHARED_SECRET)
inputs:
azureSubscription: 'azure-proxy-integration-e2e-tests'
scriptType: 'bash'
scriptLocation: 'inlineScript'
inlineScript: 'yarn e2e-deploy-infra'

- task: AzureCLI@2
inputs:
azureSubscription: 'azure-proxy-integration-e2e-tests'
scriptType: 'bash'
scriptLocation: 'inlineScript'
inlineScript: 'yarn test:e2e'
displayName: 'Run e2e tests'
env:
CI: 'true'

- task: AzureCLI@2
inputs:
azureSubscription: 'azure-proxy-integration-e2e-tests'
scriptType: 'bash'
scriptLocation: 'inlineScript'
inlineScript: 'yarn e2e-destroy-infra'
displayName: 'Destroy infrastructure'
condition: always()
env:
AZURE_STORAGE_ACCOUNT_NAME: $(AZURE_STORAGE_ACCOUNT_NAME)
AZURE_STORAGE_CONTAINER_NAME: $(AZURE_STORAGE_CONTAINER_NAME)
AZURE_STORAGE_RESOURCE_GROUP: $(AZURE_STORAGE_RESOURCE_GROUP)
AZURE_SUBSCRIPTION_ID: $(AZURE_SUBSCRIPTION_ID)
FPJS_PRE_SHARED_SECRET: $(FPJS_PRE_SHARED_SECRET)
2 changes: 2 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
trigger:
branches:
exclude:
- 'test'
include:
- '*'

Expand Down
2 changes: 1 addition & 1 deletion management/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { config } from './config'
import { isSemverGreater } from './semver'
import { Logger } from '@azure/functions'

function bearer(token?: string) {
export function bearer(token?: string) {
return `Bearer ${token}`
}

Expand Down
46 changes: 46 additions & 0 deletions scripts/downloadGithubReleasePackage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { config } from '../management/config'
import { bearer, downloadReleaseAsset, findFunctionZip, GithubRelease } from '../management/github'
import fs from 'fs'
import path from 'path'

async function main() {
const tag = process.env.TAG
const token = process.env.GITHUB_TOKEN

if (!tag) {
throw new Error('TAG environment variable is required')
}

console.debug('tag', tag)

const url = `https://api.github.com/repos/${config.repositoryOwner}/${config.repository}/releases/tags/${tag}`

console.debug('url', url)

const githubRelease: GithubRelease = await fetch(url, {
headers: token
? {
Authorization: bearer(token),
}
: undefined,
}).then((res) => res.json())

console.debug('githubRelease', githubRelease)

const functionZip = await findFunctionZip(githubRelease.assets)

console.debug('functionZip', functionZip)

if (!functionZip) {
throw new Error('No function zip found')
}

const asset = await downloadReleaseAsset(functionZip.url, token)

fs.writeFileSync(path.resolve(__dirname, '../package.zip'), asset)
}

main().catch((err) => {
console.error(err)
process.exit(1)
})
17 changes: 17 additions & 0 deletions scripts/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"types": ["node"],
"module": "CommonJS"
},
"exclude": [
"../dist",
"node_modules",
"**/*.test.ts",
"test",
"e2e"
],
"include": [
"scripts/**.ts"
]
}
5 changes: 4 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
"esModuleInterop": true,
"sourceMap": true
},
"include": ["proxy", "management"],
"include": [
"proxy",
"management"
],
"references": [
{
"path": "./tsconfig.app.json"
Expand Down

0 comments on commit 29761e5

Please sign in to comment.