Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split programming model out of worker #608

Merged
merged 8 commits into from Aug 18, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 0 additions & 26 deletions azure-pipelines/build.yml
Expand Up @@ -68,38 +68,12 @@ jobs:
publishVstsFeed: 'e6a70c92-4128-439f-8012-382fe78d6396/f37f760c-aebd-443e-9714-ce725cd427df'
allowPackageConflicts: true
displayName: 'Push NuGet package to the AzureFunctionsPreRelease feed'
# In order for the SBOM to be accurate, we want to explicitly specify the components folder, but the types package doesn't have any components
# We'll create an empty folder that _would_ store the components if it had any
- bash: |
mkdir types/node_modules
displayName: 'mkdir types/node_modules'
- task: CopyFiles@2
displayName: 'Copy types files to staging'
inputs:
sourceFolder: '$(Build.SourcesDirectory)/types'
contents: |
index.d.ts
LICENSE
package.json
README.md
targetFolder: '$(Build.ArtifactStagingDirectory)/types'
cleanTargetFolder: true
- task: ManifestGeneratorTask@0
displayName: 'Generate SBOM for types'
inputs:
BuildDropPath: '$(Build.ArtifactStagingDirectory)/types'
BuildComponentPath: '$(Build.SourcesDirectory)/types/node_modules'
PackageName: 'Azure Functions Type Definitions'
- script: npm pack
displayName: 'npm pack types'
workingDirectory: '$(Build.ArtifactStagingDirectory)/types'
- task: CopyFiles@2
displayName: 'Copy packages to staging drop folder'
inputs:
sourceFolder: '$(Build.ArtifactStagingDirectory)'
contents: |
worker/*.nupkg
types/*.tgz
targetFolder: '$(Build.ArtifactStagingDirectory)/drop'
cleanTargetFolder: true
- task: PublishPipelineArtifact@1
Expand Down
43 changes: 0 additions & 43 deletions azure-pipelines/release-types.yml

This file was deleted.

53 changes: 22 additions & 31 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 4 additions & 7 deletions package.json
Expand Up @@ -5,13 +5,12 @@
"description": "Microsoft Azure Functions NodeJS Worker",
"license": "(MIT OR Apache-2.0)",
"dependencies": {
"@azure/functions": "file:../js-framework/azure-functions-3.4.0.tgz",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we import this as the npm package?

"@grpc/grpc-js": "^1.2.7",
"@grpc/proto-loader": "^0.6.4",
"blocked-at": "^1.2.0",
"fs-extra": "^10.0.1",
"long": "^4.0.0",
"minimist": "^1.2.5",
"uuid": "^8.3.0"
"minimist": "^1.2.5"
},
"devDependencies": {
"@types/blocked-at": "^1.0.1",
Expand Down Expand Up @@ -49,8 +48,6 @@
"sinon": "^7.0.0",
"ts-node": "^3.3.0",
"typescript": "^4.5.5",
"typescript3": "npm:typescript@~3.7.0",
"typescript4": "npm:typescript@~4.0.0",
"webpack": "^5.72.1",
"webpack-cli": "^4.8.0"
},
Expand All @@ -64,13 +61,13 @@
},
"scripts": {
"clean": "rimraf dist && rimraf azure-functions-language-worker-protobuf/src/rpc*",
"build": "rimraf dist && npm run gen && shx mkdir -p dist/azure-functions-language-worker-protobuf/src && shx cp azure-functions-language-worker-protobuf/src/rpc.* dist/azure-functions-language-worker-protobuf/src/. && node ./node_modules/typescript/bin/tsc",
"build": "rimraf dist && npm run gen && shx mkdir -p dist/azure-functions-language-worker-protobuf/src && shx cp azure-functions-language-worker-protobuf/src/rpc.* dist/azure-functions-language-worker-protobuf/src/. && tsc",
hossam-nasr marked this conversation as resolved.
Show resolved Hide resolved
"gen": "node scripts/generateProtos.js",
"test": "mocha -r ts-node/register \"./test/**/*.ts\" --reporter mocha-multi-reporters --reporter-options configFile=test/mochaReporterOptions.json",
"lint": "eslint .",
"lint-fix": "eslint . --fix",
"updateVersion": "ts-node ./scripts/updateVersion.ts",
"watch": "node ./node_modules/typescript/bin/tsc --watch",
"watch": "tsc --watch",
"webpack": "webpack --mode production"
},
"files": [
Expand Down
31 changes: 2 additions & 29 deletions scripts/updateVersion.ts
Expand Up @@ -9,8 +9,6 @@ import * as semver from 'semver';

const repoRoot = path.join(__dirname, '..');
const packageJsonPath = path.join(repoRoot, 'package.json');
const typesRoot = path.join(repoRoot, 'types');
const typesPackageJsonPath = path.join(typesRoot, 'package.json');
const nuspecPath = path.join(repoRoot, 'Worker.nuspec');
const nuspecVersionRegex = /<version>(.*)\$prereleaseSuffix\$<\/version>/i;
const constantsPath = path.join(repoRoot, 'src', 'constants.ts');
Expand All @@ -24,9 +22,6 @@ if (args.validate) {
} else {
console.log(`This script can be used to either update the version of the worker or validate that the repo is in a valid state with regards to versioning.

NOTE: For the types package, only the major & minor version need to match the worker. We follow the same pattern as DefinitelyTyped as described here:
https://github.com/DefinitelyTyped/DefinitelyTyped#how-do-definitely-typed-package-versions-relate-to-versions-of-the-corresponding-library

Example usage:

npm run updateVersion -- --version 3.3.0
Expand All @@ -39,35 +34,21 @@ function validateVersion() {
const packageJson = readJSONSync(packageJsonPath);
const packageJsonVersion = packageJson.version;

const typesPackageJson = readJSONSync(typesPackageJsonPath);
const typesPackageJsonVersion = typesPackageJson.version;

const nuspecVersion = getVersion(nuspecPath, nuspecVersionRegex);

const constantsVersion = getVersion(constantsPath, constantsVersionRegex);

console.log('Found the following versions:');
console.log(`- package.json: ${packageJsonVersion}`);
console.log(`- types/package.json: ${typesPackageJsonVersion}`);
console.log(`- Worker.nuspec: ${nuspecVersion}`);
console.log(`- src/constants.ts: ${constantsVersion}`);

const parsedVersion = semver.parse(packageJsonVersion);
const parsedTypesVersion = semver.parse(typesPackageJsonVersion);

if (
!packageJsonVersion ||
!nuspecVersion ||
!constantsVersion ||
!typesPackageJsonVersion ||
!parsedVersion ||
!parsedTypesVersion
) {

if (!packageJsonVersion || !nuspecVersion || !constantsVersion || !parsedVersion) {
throw new Error('Failed to detect valid versions in all expected files');
} else if (nuspecVersion !== packageJsonVersion || constantsVersion !== packageJsonVersion) {
throw new Error(`Worker versions do not match.`);
} else if (parsedVersion.major !== parsedTypesVersion.major || parsedVersion.minor !== parsedTypesVersion.minor) {
throw new Error(`Types package does not match the major/minor version of the worker.`);
} else {
console.log('Versions match! 🎉');
}
Expand All @@ -84,15 +65,7 @@ function getVersion(filePath: string, regex: RegExp): string {

function updateVersion(newVersion: string) {
updatePackageJsonVersion(repoRoot, newVersion);

if (newVersion.endsWith('.0')) {
updatePackageJsonVersion(typesRoot, newVersion);
} else {
console.log(`Skipping types/package.json because this is a patch version.`);
}

updateVersionByRegex(nuspecPath, nuspecVersionRegex, newVersion);

updateVersionByRegex(constantsPath, constantsVersionRegex, newVersion);
}

Expand Down