Skip to content

Commit

Permalink
Added workflow for releasing.
Browse files Browse the repository at this point in the history
  • Loading branch information
jfeingold35 committed Aug 31, 2023
1 parent ce9a85b commit 72f1678
Show file tree
Hide file tree
Showing 8 changed files with 852 additions and 45 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/create-vsix-artifact.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: create-vsix-artifact
on:
workflow_call:
workflow_dispatch:

jobs:
build-and-upload:
Expand All @@ -13,9 +14,9 @@ jobs:
with:
node-version: 'lts/*' # Node LTS should always be fine.
- name: 'Install node dependencies'
run: yarn && yarn global add @vscode/vsce
run: yarn install --frozen-lockfile
- name: 'Create VSIX'
run: vsce package
run: npx vsce package
- name: 'Upload artifact'
uses: actions/upload-artifact@v3
with:
Expand Down
116 changes: 116 additions & 0 deletions .github/workflows/publishVSCode.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
name: Publish in Microsoft Marketplace
on:
release:
# This limits the workflow to releases that are not pre-releases.
# From the docs: A release was published, or a pre-release was changed to a release.
types: [released]
# Button for publishing main branch in case there's a failure on the release.
workflow_dispatch:
inputs:
tag:
description: Tag to be published
type: string
required: true

jobs:
validate-release-environment:
runs-on: ubuntu-latest
outputs:
RELEASE_VERSION: ${{ steps.get-package-version.outputs.PACKAGE_VERSION }}
GUS_BUILD: ${{ steps.get-gus-build.outputs.GUS_BUILD }}
SF_CHANGE_CASE_SCHEDULE_BUILD: ${{ steps.get-scheduled-build.outputs.SF_CHANGE_CASE_SCHEDULE_BUILD }}
steps:
# Check out the release branch and get its head commit as output for later.
- uses: actions/checkout@v3
with:
ref: 'main'
- id: get-branch-commit
run: echo "COMMIT_ID=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
# Check out the tag to be released and get its head commit as output for later.
- uses: actions/checkout@v3
with:
ref: ${{ github.event.release.tag_name || inputs.tag }}
- id: get-tag-commit
run: echo "COMMIT_ID=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
# If the two commits aren't identical, the tag isn't eligible for release.
- name: Fail non-matching commits
if: ${{ steps.get-branch-commit.outputs.COMMIT_ID != steps.get-tag-commit.outputs.COMMIT_ID }}
run: |
echo "Tag commit must match latest commit in main. Branch is ${{ steps.get-branch-commit.outputs.COMMIT_ID }}. Tag is ${{ steps.get-tag-commit.outputs.COMMIT_ID }}."
exit 1
# Get the `version` property from `package.json` as output for later.
- name: Get package.json version property
id: get-package-version
run: |
echo "PACKAGE_VERSION=$(cat package.json | jq '.version' | xargs)" >> $GITHUB_OUTPUT
- run: echo "Package Version is ${{ steps.get-package-version.outputs.PACKAGE_VERSION }}"
# Verify that the tag is of the format "vX.Y.Z", exactly matching the corresponding values in the `package.json` version property.
- name: Compare tag to package.json
run: |
TAG=${{ github.event.release.tag_name || inputs.tag }}
PACKAGE_VERSION=v${{ steps.get-package-version.outputs.PACKAGE_VERSION }}
[[ ${TAG} == ${PACKAGE_VERSION} ]] || (echo "Tag name must match package.json version, prefixed by lowercase v" && exit 1)
# Set other miscellaneous environment variables as outputs for later.
- id: get-gus-build
run: echo "GUS_BUILD=${{ steps.get-package-version.outputs.PACKAGE_VERSION }}" >> $GITHUB_OUTPUT
- run: echo "GUS BUILD IS ${{ steps.get-gus-build.outputs.GUS_BUILD }}"
- id: get-scheduled-build
run: echo "SF_CHANGE_CASE_SCHEDULE_BUILD=offcore.tooling.${{ steps.get-package-version.outputs.PACKAGE_VERSION }}" > $GITHUB_OUTPUT
- run: echo "SF_CHANGE_CASE_SCHEDULE_BUILD is ${{ steps.get-scheduled-build.outputs.SF_CHANGE_CASE_SCHEDULE_BUILD }}"

ctc-open:
needs: [ validate-release-environment ]
uses: salesforcecli/github-workflows/.github/workflows/ctcOpen.yml@main
secrets: inherit

publish:
needs: [ 'ctc-open', 'validate-release-environment' ]
runs-on: ubuntu-latest
env:
VSCE_PERSONAL_ACCESS_TOKEN: ${{ secrets.VSCE_PERSONAL_ACCESS_TOKEN }}
PUBLISH_VERSION: ${{ needs.validate-release-environment.outputs.RELEASE_VERSION }}
GITHUB_TOKEN: ${{ secrets.IDEE_GH_TOKEN }}
steps:
- name: Checkout the release tag
uses: actions/checkout@v3
with:
ref: ${{ github.event.release.tag_name || inputs.tag }}
token: ${{ secrets.IDEE_GH_TOKEN }}
# Set up node and install dependencies.
- uses: actions/setup-node@v3
with:
node-version: 'lts/*'
- run: yarn install --frozen-lockfile
# Download the .vsix attached to the release.
- name: Download Extension From Release
run: |
mkdir ./extensions
gh release download v${{ env.PUBLISH_VERSION }} -D ./extensions
- name: Display downloaded VSIX
run: ls -R ./extensions
- name: Publish the VSIX
run: find ./extensions -type f -name "*.vsix" -exec npx vsce publish --pat ${{ env.VSCE_PERSONAL_ACCESS_TOKEN }} --packagePath {} \;
- run: echo "SUCCESSFULLY PUBLISHED"

ctc-close-success:
needs: [ ctc-open, publish ]
if: needs.ctc-open.result == 'success' && needs.publish.result == 'success' && needs.ctc-open.outputs.changeCaseId
uses: salesforcecli/github-workflows/.github/workflows/ctcClose.yml@main
secrets: inherit
with:
changeCaseId: ${{ needs.ctc-open.outputs.changeCaseId }}

ctc-close-fail:
needs: [ ctc-open, publish ]
if: always() && inputs.ctc && needs.ctc-open.outputs.changeCaseId && (needs.ctc-open.result != 'success' || needs.publish.result != 'success')
uses: salesforcecli/github-workflows/.github/workflows/ctcClose.yml@main
secrets: inherit
with:
changeCaseId: ${{ needs.ctc-open.outputs.changeCaseId }}
status: Not Implemented






3 changes: 2 additions & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: run-tests
on:
workflow_call:
workflow_dispatch:

jobs:
build-and-run:
Expand All @@ -16,7 +17,7 @@ jobs:
with:
node-version: 'lts/*' # Node LTS should always be fine.
- name: 'Install node module dependencies'
run: yarn
run: yarn install --frozen-lockfile
- name: 'Run Unit Tests (Linux)'
run: xvfb-run -a yarn test
if: runner.os == 'Linux'
Expand Down
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,24 @@ To report issues with the Salesforce Code Analyzer VS Code Extension, create a [

---

Currently, Visual Studio Code extensions aren't signed or verified on the Microsoft Visual Studio Code Marketplace. Salesforce provides the Secure Hash Algorithm (SHA) of each extension that we publish. To learn how to verify the extensions, consult [Manually Verify the salesforcedx-vscode Extensions' Authenticity](https://developer.salesforce.com/media/vscode/SHA256.md).
Currently, Visual Studio Code extensions aren't signed or verified on the Microsoft Visual Studio Code Marketplace. Salesforce provides the Secure Hash Algorithm (SHA) of each extension that we publish. To learn how to verify the extensions, consult [Manually Verify the salesforcedx-vscode Extensions' Authenticity](https://developer.salesforce.com/media/vscode/SHA256.md).

---

**Terms of Use for the Code Analyzer VS Code Extension (Beta)**

Copyright 2023 Salesforce, Inc. All rights reserved.

These Terms of Use govern the download, installation, and/or use of the beta Code Analyzer VS Code Extension provided by Salesforce, Inc. (“Salesforce”) (the “Extension”).

**License**: Salesforce grants you a non-transferable, non-sublicensable, non-exclusive license to use the Extension, at no charge, subject to these Terms. Salesforce reserves all rights, title, and interest in and to the Extension.

**Feedback**: You agree to provide ongoing feedback regarding the Extension, and Salesforce shall have a royalty-free, worldwide, irrevocable, perpetual license to use and incorporate into its products and services any feedback you provide.

**Data Privacy**: Salesforce may collect, process, and store device, system, and other information related to use of the Extension. This information may include, but is not limited to, IP address, user metrics, and other data (“Usage Data”). Salesforce may use Usage Data for analytics, product development, and marketing purposes. You are solely responsible for anonymizing and protecting any sensitive or confidential data.

**No Warranty**: THE EXTENSION IS NOT SUPPORTED AND IS PROVIDED “AS-IS,” EXCLUSIVE OF ANY WARRANTY WHATSOEVER, WHETHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE. SALESFORCE DISCLAIMS ALL IMPLIED WARRANTIES, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW. The Extension may contain bugs, errors, and/or incompatibilities, and its use is at your sole risk. You acknowledge that Salesforce may discontinue the Extension at any time, with or without notice, in its sole discretion, and may never make it generally available.

**No Damages**: IN NO EVENT SHALL SALESFORCE HAVE ANY LIABILITY FOR ANY DAMAGES WHATSOEVER, INCLUDING BUT NOT LIMITED TO DIRECT, INDIRECT, SPECIAL, INCIDENTAL, PUNITIVE, OR CONSEQUENTIAL DAMAGES, OR DAMAGES BASED ON LOST PROFITS, DATA, OR USE, HOWEVER CAUSED AND, WHETHER IN CONTRACT, TORT, OR UNDER ANY OTHER THEORY OF LIABILITY, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

**Governing Law**: These Terms and the Extension shall be governed exclusively by the internal laws of the State of California, without regard to its conflicts of laws rules. You and Salesforce agree to the exclusive jurisdiction of the state and federal courts in San Francisco County, California.
27 changes: 27 additions & 0 deletions SHA256.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Currently, Visual Studio Code extensions are not signed or verified on the
Microsoft Visual Studio Code Marketplace. Salesforce provides the Secure Hash
Algorithm (SHA) of each extension that we publish. To verify the extensions,
make sure that their SHA values match the values in the list below.

1. Instead of installing the Visual Code Extension directly from within Visual
Studio Code, download the VS Code extension that you want to check by
following the instructions at
https://code.visualstudio.com/docs/editor/extension-gallery#_common-questions.
For example, download,
https://salesforce.gallery.vsassets.io/_apis/public/gallery/publisher/salesforce/extension/salesforcedx-vscode-core/57.15.0/assetbyname/Microsoft.VisualStudio.Services.VSIXPackage.

2. From a terminal, run:

shasum -a 256 <location_of_the_downloaded_file>

3. Confirm that the SHA in your output matches the value in this list of SHAs.
42904484bfbb7ad78f6757486a75d5eb8442886ce99d1874edef1e4865597e6e ./extensions/salesforcedx-vscode-apex-58.4.1.vsix
cfe2bcb4000dc37a885c10ccb92c618c94133aa6c1ff2070431417a2955f3d70 ./extensions/salesforcedx-vscode-core-58.4.1.vsix
faf777f5425ab82a7d4c2261a82c7e4da7824cace3946e5291a349e1f9d97aae ./extensions/salesforcedx-einstein-gpt-0.17.0.vsix
4. Change the filename extension for the file that you downloaded from .zip to
.vsix.

5. In Visual Studio Code, from the Extensions view, select ... > Install from
VSIX.

6. Install the verified VSIX file.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
"eslint": "^8.28.0",
"mocha": "^10.1.0",
"sinon": "^15.1.0",
"typescript": "^4.9.3"
"typescript": "^4.9.3",
"vsce": "2.15.0"
},
"scripts": {
"vscode:prepublish": "yarn run compile",
Expand Down
20 changes: 10 additions & 10 deletions src/lib/fixer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class Fixer implements vscode.CodeActionProvider {
// Iterate over all diagnostics.
return context.diagnostics
// Throw out diagnostics that aren't ours, or are for the wrong line.
.filter(diagnostic => messages.diagnostics.source.isSource(diagnostic.source) && diagnostic.range.isEqual(range))
.filter(diagnostic => messages.diagnostics.source && messages.diagnostics.source.isSource(diagnostic.source) && diagnostic.range.isEqual(range))
// Get and use the appropriate fix generator.
.map(diagnostic => this.getFixGenerator(document, diagnostic).generateFixes())
// Combine all the fixes into one array.
Expand All @@ -32,9 +32,9 @@ export class Fixer implements vscode.CodeActionProvider {
/**
* Gets a {@link FixGenerator} corresponding to the engine that created the given diagnostic,
* or a {@link _NoOpFixGenerator} if no engine-specific generator is available.
* @param document
* @param diagnostic
* @returns
* @param document
* @param diagnostic
* @returns
*/
private getFixGenerator(document: vscode.TextDocument, diagnostic: vscode.Diagnostic): FixGenerator {
const engine: string = messages.diagnostics.source.extractEngine(diagnostic.source);
Expand All @@ -58,7 +58,7 @@ abstract class FixGenerator {
protected diagnostic: vscode.Diagnostic;

/**
*
*
* @param document A document to which fixes should be added
* @param diagnostic The diagnostic from which fixes should be generated
*/
Expand Down Expand Up @@ -91,7 +91,7 @@ export class _NoOpFixGenerator extends FixGenerator {
export class _PmdFixGenerator extends FixGenerator {
/**
* Generate an array of fixes, if possible.
* @returns
* @returns
*/
public generateFixes(): vscode.CodeAction[] {
const fixes: vscode.CodeAction[] = [];
Expand All @@ -104,17 +104,17 @@ export class _PmdFixGenerator extends FixGenerator {
/**
* Not all languages support line-level PMD violation suppression. This method
* verifies that the target document does.
* @returns
* @returns
*/
private documentSupportsLineLevelSuppression(): boolean {
const lang = this.document.languageId;
// Of the languages we support, Apex and Java are the ones
// that support line-level suppression.
return lang === 'apex' || lang === 'java';
}

/**
*
*
* @returns An action that will apply a line-level suppression to the targeted diagnostic.
*/
private generateLineLevelSuppression(): vscode.CodeAction {
Expand All @@ -127,4 +127,4 @@ export class _PmdFixGenerator extends FixGenerator {
action.diagnostics = [this.diagnostic];
return action;
}
}
}
Loading

0 comments on commit 72f1678

Please sign in to comment.