From 0bed54f6df3113e4cd89b9bc1f61c4bb8b5cb27b Mon Sep 17 00:00:00 2001 From: Rachelle Rathbone Date: Wed, 13 Dec 2023 09:15:05 +1100 Subject: [PATCH 1/2] removing --- .github/workflows/codeql-analysis.yml | 24 ------------- .github/workflows/codeql.yml | 52 --------------------------- 2 files changed, 76 deletions(-) delete mode 100644 .github/workflows/codeql-analysis.yml delete mode 100644 .github/workflows/codeql.yml diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml deleted file mode 100644 index 9879099b..00000000 --- a/.github/workflows/codeql-analysis.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: "Code scanning - action" - -on: - push: - schedule: - - cron: '0 4 * * 0' - -jobs: - CodeQL-Build: - - strategy: - fail-fast: false - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v2 - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v1 - - name: Autobuild - uses: github/codeql-action/autobuild@v1 - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml deleted file mode 100644 index 10da2cdb..00000000 --- a/.github/workflows/codeql.yml +++ /dev/null @@ -1,52 +0,0 @@ -name: "Code scanning - action" - -on: - push: - pull_request: - schedule: - - cron: '0 19 * * 0' - -jobs: - CodeQL-Build: - - # CodeQL runs on ubuntu-latest and windows-latest - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v2 - with: - # We must fetch at least the immediate parents so that if this is - # a pull request then we can checkout the head. - fetch-depth: 2 - - # If this run was triggered by a pull request event, then checkout - # the head of the pull request instead of the merge commit. - - run: git checkout HEAD^2 - if: ${{ github.event_name == 'pull_request' }} - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v1 - # Override language selection by uncommenting this and choosing your languages - # with: - # languages: go, javascript, csharp, python, cpp, java - - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v1 - - # ℹī¸ Command-line programs to run using the OS shell. - # 📚 https://git.io/JvXDl - - # ✏ī¸ If the Autobuild fails above, remove it and uncomment the following three lines - # and modify them (or add more) to build your code if your project - # uses a compiled language - - #- run: | - # make bootstrap - # make release - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 From 2d45ea66baf795665dd4fc8c1ab7dfaa1025dd49 Mon Sep 17 00:00:00 2001 From: Rachelle Rathbone Date: Wed, 13 Dec 2023 11:34:27 +1100 Subject: [PATCH 2/2] refactor to be more generic --- .../src/api/redirectFromGetStarted.test.ts | 4 ++-- app/jenkins-for-jira-ui/src/api/redirectFromGetStarted.ts | 2 +- app/src/resolvers.ts | 6 +++--- ...ct-from-get-started.test.ts => fetch-app-data.test.ts} | 8 ++++---- .../{redirect-from-get-started.ts => fetch-app-data.ts} | 6 +++--- 5 files changed, 13 insertions(+), 13 deletions(-) rename app/src/utils/{redirect-from-get-started.test.ts => fetch-app-data.test.ts} (72%) rename app/src/utils/{redirect-from-get-started.ts => fetch-app-data.ts} (74%) diff --git a/app/jenkins-for-jira-ui/src/api/redirectFromGetStarted.test.ts b/app/jenkins-for-jira-ui/src/api/redirectFromGetStarted.test.ts index 6f55cd3c..643f0903 100644 --- a/app/jenkins-for-jira-ui/src/api/redirectFromGetStarted.test.ts +++ b/app/jenkins-for-jira-ui/src/api/redirectFromGetStarted.test.ts @@ -16,7 +16,7 @@ describe('redirectFromGetStarted', () => { (invoke as jest.Mock).mockResolvedValue(contextData); await redirectFromGetStarted(); - expect(invoke).toHaveBeenCalledWith('redirectFromGetStarted'); + expect(invoke).toHaveBeenCalledWith('fetchAppData'); expect(router.navigate).toHaveBeenCalledWith( `${contextData.siteUrl}/jira/settings/apps/${contextData.appId}/${contextData.environmentId}/` ); @@ -33,7 +33,7 @@ describe('redirectFromGetStarted', () => { (invoke as jest.Mock).mockResolvedValue(contextData); await redirectFromGetStarted(); - expect(invoke).toHaveBeenCalledWith('redirectFromGetStarted'); + expect(invoke).toHaveBeenCalledWith('fetchAppData'); expect(router.navigate).not.toHaveBeenCalledWith( `${contextData.siteUrl}/jira/settings/apps/${contextData.appId}/${contextData.environmentId}/` ); diff --git a/app/jenkins-for-jira-ui/src/api/redirectFromGetStarted.ts b/app/jenkins-for-jira-ui/src/api/redirectFromGetStarted.ts index 7992369a..3d88e96f 100644 --- a/app/jenkins-for-jira-ui/src/api/redirectFromGetStarted.ts +++ b/app/jenkins-for-jira-ui/src/api/redirectFromGetStarted.ts @@ -8,7 +8,7 @@ interface Context { } const redirectFromGetStarted = async (): Promise => { - const context: Context = await invoke('redirectFromGetStarted'); + const context: Context = await invoke('fetchAppData'); const { siteUrl, appId, diff --git a/app/src/resolvers.ts b/app/src/resolvers.ts index 2c2badfd..f1579cc3 100644 --- a/app/src/resolvers.ts +++ b/app/src/resolvers.ts @@ -12,7 +12,7 @@ import { deleteDeployments } from './jira-client/delete-deployments'; import { adminPermissionCheck } from './check-permissions'; import { metricResolverEmitter } from './common/metric-names'; import { generateNewSecret } from './storage/generate-new-secret'; -import { RedirectFromGetStarted, redirectFromGetStarted } from './utils/redirect-from-get-started'; +import { FetchAppDataProps, fetchAppData } from './utils/fetch-app-data'; import { fetchFeatureFlag } from './config/feature-flags'; const resolver = new Resolver(); @@ -82,10 +82,10 @@ resolver.define('fetchCloudId', async (req): Promise => { return req.context.cloudId; }); -resolver.define('redirectFromGetStarted', async (req): Promise => { +resolver.define('fetchAppData', async (req): Promise => { await adminPermissionCheck(req); internalMetrics.counter(metricResolverEmitter.generateNewSecretForServer).incr(); - return redirectFromGetStarted(req); + return fetchAppData(req); }); export default resolver.getDefinitions(); diff --git a/app/src/utils/redirect-from-get-started.test.ts b/app/src/utils/fetch-app-data.test.ts similarity index 72% rename from app/src/utils/redirect-from-get-started.test.ts rename to app/src/utils/fetch-app-data.test.ts index b9d4a13f..9283f49e 100644 --- a/app/src/utils/redirect-from-get-started.test.ts +++ b/app/src/utils/fetch-app-data.test.ts @@ -1,7 +1,7 @@ -import { redirectFromGetStarted, RedirectFromGetStarted } from './redirect-from-get-started'; +import { fetchAppData, FetchAppDataProps } from './fetch-app-data'; describe('redirectFromGetStarted', () => { - it('should return the expected RedirectFromGetStarted object', () => { + it('should return the expected FetchAppData object', () => { const mockRequest = { context: { siteUrl: 'https://testjira.com', @@ -12,14 +12,14 @@ describe('redirectFromGetStarted', () => { }, }; - const result: RedirectFromGetStarted = redirectFromGetStarted(mockRequest); + const result: FetchAppDataProps = fetchAppData(mockRequest); const { siteUrl, appId, environmentId, moduleKey } = mockRequest.context; - const expected: RedirectFromGetStarted = { + const expected: FetchAppDataProps = { siteUrl, appId, environmentId, diff --git a/app/src/utils/redirect-from-get-started.ts b/app/src/utils/fetch-app-data.ts similarity index 74% rename from app/src/utils/redirect-from-get-started.ts rename to app/src/utils/fetch-app-data.ts index b5eacc21..7d9dc743 100644 --- a/app/src/utils/redirect-from-get-started.ts +++ b/app/src/utils/fetch-app-data.ts @@ -1,13 +1,13 @@ import { extractAppIdFromLocalId } from './extract-app-id-from-local-id'; -export type RedirectFromGetStarted = { +export type FetchAppDataProps = { siteUrl: string, appId: string, environmentId: string, moduleKey: string }; -const redirectFromGetStarted = (request: any): RedirectFromGetStarted => { +const fetchAppData = (request: any): FetchAppDataProps => { const { localId, siteUrl, @@ -24,4 +24,4 @@ const redirectFromGetStarted = (request: any): RedirectFromGetStarted => { }; }; -export { redirectFromGetStarted }; +export { fetchAppData };