-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[storage] Updates to samples for CI and local runs #6496
Conversation
Will this apply to queue and file-datalake? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Runnable samples!
["basic", basicMain], | ||
["customPipeline", customPipelineMain], | ||
["iterators-files-and-directories", iteratorsFilesAndDirectoriesMain], | ||
// ["iterators-handles", iteratorsHandlesMain], // Must be populated with a pre-existing share/directory name to run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you just add in the name of the share to the sample.env and let the user fill them in?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes but it would still require that it already exists, so we would have to then have some external way to mask it out for CI. I think a better solution is to modify the sample so that it doesn't rely on any pre-existing resources.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not understanding this bit:
I think a better solution is to modify the sample so that it doesn't rely on any pre-existing resources.
This is true but by the time the sample runs how/when the resource was created doesn't really matter, only that the environment variables point to the right thing. So it still seems like having those values specified in the sample.env makes sense to me.
SDK developers will create the identity once, the storage account once and just use that over and over (via .env)
CI will create the identity multiple times, the storage account multiple times and just use that over and over (by injecting environment variables directly).
Or am I missing how you want to do this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of the rest of the examples in the storage packages create and tear down their resources dynamically, and the only thing they need is an account. I think we should just have this sample do the same thing. What I'm going to do for now is just make the samples exit if they aren't configured, and so this one will run fine in the runner if the environment variables aren't set up. It'll just log a message and skip itself. I'll add the variables to sample.env for customers' sake, but our CI shouldn't have to provision a share and a directory with some open handles to run this sample since that's a lot for the CI harness to have to set up and I'm not even sure if it could do that.
@@ -0,0 +1,9 @@ | |||
# Used in most samples. Retrieve these values from a storage account in the Azure Portal. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For your identity tests you're welcome to copy the lines that I also copied from somewhere else:
# Used in the usingAadAuth.ts sample |
That way they don't have to enter the credentials in the environment (or paste them into their source code).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can standardize on something between: maybe a quick set of instructions and links to the docs for EnvironmentCredential in identity
@XiaoningLiu I'm working on Queue today, and it will apply to files-datalake eventually, but datalake isn't on my list of packages to take care of immediately. |
common/scripts/prep-samples.js
Outdated
writeFile: promisify(baseFS.writeFile) | ||
}; | ||
})(); | ||
|
||
/** | ||
* Breadth-first search for files ending in .ts, starting from `tsDir` | ||
* Breadth-first search for files matching a given predicate | ||
* | ||
* @param {string} tsDir The root of the sample tree to search |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: tsDir
=> dir
"keywords": [ | ||
"Azure", | ||
"Storage", | ||
"File", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
File [](start = 5, length = 4)
Minor. Should be "Queue", please check other package.json files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const { AnonymousCredential, BlobServiceClient, newPipeline } = require("../.."); // Change to "@azure/storage-blob" in your package | ||
const { AnonymousCredential, BlobServiceClient, newPipeline } = require("@azure/storage-blob"); | ||
|
||
const { runSample } = require("./sampleHelpers"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this is addressed already.. this would confuse users?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Offline discussion with Will..
- We are going to provide samples through docs.microsoft.com similar to below
https://docs.microsoft.com/en-ca/samples/browse/?products=azure-storage&languages=javascript%2Cnodejs- separate zipped folders for javascript and typescript samples - just like the
Download Zip
link here. - In the bullet-list of links in the readmes,
docs.microsoft.com/samples
link will be provided instead of the samples folder link - js samples are located at
samples/javascript
whereas the ts samples are atsamples/typescript/src
- separate zipped folders for javascript and typescript samples - just like the
- To improve user-convenience of just copy/pasting one single sample, @willmtemple will be looking to remove
./sampleHelpers
part of the samples
@HarshaNalluru most recent changes modify |
/azp run js - storage-queue - tests |
Azure Pipelines successfully started running 1 pipeline(s). |
"extract-api": "tsc -p . && api-extractor run --local", | ||
"execute:samples": "node execute-samples.js", | ||
"execute:js-samples": "node ../../../common/scripts/run-samples.js samples/javascript/", | ||
"execute:ts-samples": "node ../../../common/scripts/run-samples.js samples/typescript/dist/samples/typescript/src/", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[NIT]
samples/typescript/dist/samples/typescript/src/
?
samples/typescript/dist/
is not enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, because it is not using the rollup artifact. It is actually importing the package sources as modules, so the tree in samples/typescript/dist
after compilation looks something like this:
dist/
- samples/
- typescript/
- src/
- basic.js
- ... (compiled sample code)
- src/
- StorageClient.js
- ... (compiled client code)
An alternative would be to use ts-node
rather than compile and run the samples, like the previous script was doing, but that has its own set of problems (would need to make the *-samples scripts their own package and add ts-node as a dependency, otherwise we would be requiring global ts-node -- more than I think I can get done before leaving for the holidays).
/azp run js - storage-blob - tests |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run js - storage-file-share - tests |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run js - storage-file-share - tests |
Azure Pipelines successfully started running 1 pipeline(s). |
This last yellow check looks like it's stuck. AzP says that all pipelines have passed, so I am merging this. |
A lot of changes here. All addressing some different things. This is part of the work for #5679
npm run execute:samples
. This command will prep, build, and run both the TS and JS samples (fixes part two of Samples run fails in CI #6362 )npm install && npm run execute:all
npm run execute:all
, which replaces execute-samples.js and ensures that our CI process will mirror the user process