Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @kaverma @kanika1894 @BALAGA-GAYATRI @pulkitaggarwl
* @surenderssm @sarsharma @ShilpiRachna1 @kumaramit-msft @CodingIsBliss @Saipriya-1144 @prathambande @Shi1810 @kumaraksh1
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:

- name: 'Validate build'
run: |
npm install
npm ci
npm run build

- name: 'Run L0 tests'
Expand Down
111 changes: 111 additions & 0 deletions .github/workflows/github_actions_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# More GitHub Actions for Azure: https://github.com/Azure/actions

name: Build and deploy to Azure App Services

on:
push:
branches:
- master
schedule:
- cron: "0 0/3 * * *"

jobs:
build-and-deploy-dotnet-app:
runs-on: ubuntu-latest

permissions:
id-token: write

steps:
- uses: actions/checkout@v4

- name: Modify the sample app
run: |
cp -r ./__tests__/dotnetsampleapp dotnetapp
current_utc_time=$(date -u +"%Y-%m-%d %H:%M:%S %Z")
sed -i "s/<<<net-place-holder>>>/$current_utc_time/g" dotnetapp/Controllers/HelloController.cs

echo "The placeholder has been replaced with current UTC time: $current_utc_time"

- name: Set up .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.x'

- name: Build with dotnet
run: dotnet build --configuration Release dotnetapp/DOTNET_8_APP.csproj

- name: dotnet publish
run: dotnet publish dotnetapp/DOTNET_8_APP.csproj -c Release -o myapp

- name: Upload artifact for deployment job
uses: actions/upload-artifact@v4
with:
name: .net-app
path: myapp

- name: Login to Azure
uses: azure/login@v2
with:
client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_DOTNETAPP1 }}
tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID }}
subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID }}

- name: Deploy to Azure Web App
id: deploy-to-webapp
uses: azure/webapps-deploy@v3
with:
app-name: 'lwasv2-euap-dotnet-githubactionstest'
slot-name: 'Production'
package: myapp

build-and-deploy-node-app:
runs-on: ubuntu-latest

permissions:
id-token: write

steps:
- uses: actions/checkout@v4

- name: modify Node.js App
run: |
cp -r ./__tests__/nodesampleapp nodeapp
current_utc_time=$(date -u +"%Y-%m-%d %H:%M:%S %Z")
sed -i "s/<<<node-place-holder>>>/$current_utc_time/g" nodeapp/server.js

echo "The placeholder has been replaced with current UTC time: $current_utc_time"

- name: Set up Node.js version
uses: actions/setup-node@v3
with:
node-version: '18.x'

- name: npm ci, build, and test
run: |
cd nodeapp
npm ci
npm run build --if-present
npm run test --if-present

- name: Upload artifact for deployment job
uses: actions/upload-artifact@v4
with:
name: node-app
path: nodeapp

- name: Login to Azure
uses: azure/login@v2
with:
client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_NODEAPP1 }}
tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID }}
subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID }}

- name: 'Deploy to Azure Web App'
id: deploy-to-webapp
uses: azure/webapps-deploy@v3
with:
app-name: 'lwasv2-euap-node-githubactions'
slot-name: 'Production'
package: nodeapp
7 changes: 2 additions & 5 deletions .github/workflows/pr_check_webapp_dotnet_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,8 @@ jobs:
- name: Installing dependencies and building latest changes
run: |
cd webapps-deploy
if (-NOT(TEST-PATH node_modules))
{
npm install
npm run build
}
npm ci
npm run package

- name: Azure authentication
uses: azure/login@v2
Expand Down
7 changes: 2 additions & 5 deletions .github/workflows/pr_check_windows_container_pubprofile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,8 @@ jobs:
- name: Installing dependencies and building latest changes in action
run: |
cd webapps-deploy
if (-NOT(TEST-PATH node_modules))
{
npm install
npm run build
}
npm ci
npm run package

- name: 'Deploy to Azure WebApp'
uses: ./webapps-deploy/
Expand Down
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore

# Bundled output (built during release)
# dist/
lib/

# User-specific files
*.suo
*.user
Expand Down Expand Up @@ -261,7 +265,7 @@ FakesAssemblies/

# Node.js Tools for Visual Studio
.ntvs_analysis.dat
# node_modules/
node_modules/

# Visual Studio 6 build log
*.plg
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ jobs:
uses: actions/setup-node@v1
with:
node-version: '10.x'
- name: 'npm install, build, and test'
- name: 'npm ci, build, and test'
run: |
npm install
npm ci
npm run build --if-present
npm run test --if-present

Expand Down
105 changes: 105 additions & 0 deletions __tests__/DeploymentProvider/BaseWebAppDeploymentProvider.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import { DEPLOYMENT_PROVIDER_TYPES } from '../../src/DeploymentProvider/Providers/BaseWebAppDeploymentProvider';

// Mock dependencies
jest.mock('@actions/core');
jest.mock('../../src/actionparameters');
jest.mock('azure-actions-appservice-rest/Arm/azure-app-service');
jest.mock('azure-actions-appservice-rest/Utilities/AzureAppServiceUtility');
jest.mock('azure-actions-appservice-rest/Kudu/azure-app-kudu-service');
jest.mock('azure-actions-appservice-rest/Utilities/KuduServiceUtility');

import * as core from '@actions/core';
import { ActionParameters } from '../../src/actionparameters';
import { AzureAppServiceUtility } from 'azure-actions-appservice-rest/Utilities/AzureAppServiceUtility';

describe('Test BaseWebAppDeploymentProvider', () => {

beforeEach(() => {
jest.clearAllMocks();

// Mock ActionParameters
(ActionParameters.getActionParams as jest.Mock) = jest.fn().mockReturnValue({
endpoint: {},
resourceGroupName: 'test-rg',
appName: 'test-app',
slotName: 'production'
});
});

describe('getWarmupInstanceId', () => {

it('should return first instance when sorted alphabetically', async () => {
// Arrange
const mockInstances = {
value: [
{ name: 'instance-c' },
{ name: 'instance-a' },
{ name: 'instance-b' }
]
};

const mockGetAppserviceInstances = jest.fn().mockResolvedValue(mockInstances);
const mockGetKuduService = jest.fn().mockResolvedValue({});
const mockGetApplicationURL = jest.fn().mockResolvedValue('https://test-app.azurewebsites.net');

(AzureAppServiceUtility as jest.Mock).mockImplementation(() => ({
getAppserviceInstances: mockGetAppserviceInstances,
getKuduService: mockGetKuduService,
getApplicationURL: mockGetApplicationURL
}));

// Act - We need to create a concrete implementation to test
const { WebAppDeploymentProvider } = await import('../../src/DeploymentProvider/Providers/WebAppDeploymentProvider');
const provider = new WebAppDeploymentProvider(DEPLOYMENT_PROVIDER_TYPES.SPN);
await provider.PreDeploymentStep();

// Assert
expect(mockGetAppserviceInstances).toHaveBeenCalled();
// instance-a should be selected (first alphabetically)
expect(mockGetKuduService).toHaveBeenCalledWith('instance-a');
});

it('should return undefined when no instances are available', async () => {
// Arrange
const mockGetAppserviceInstances = jest.fn().mockResolvedValue({ value: [] });
const mockGetKuduService = jest.fn().mockResolvedValue({});
const mockGetApplicationURL = jest.fn().mockResolvedValue('https://test-app.azurewebsites.net');

(AzureAppServiceUtility as jest.Mock).mockImplementation(() => ({
getAppserviceInstances: mockGetAppserviceInstances,
getKuduService: mockGetKuduService,
getApplicationURL: mockGetApplicationURL
}));

// Act
const { WebAppDeploymentProvider } = await import('../../src/DeploymentProvider/Providers/WebAppDeploymentProvider');
const provider = new WebAppDeploymentProvider(DEPLOYMENT_PROVIDER_TYPES.SPN);
await provider.PreDeploymentStep();

// Assert
expect(mockGetKuduService).toHaveBeenCalledWith(undefined);
});

it('should handle errors gracefully and return undefined', async () => {
// Arrange
const mockGetAppserviceInstances = jest.fn().mockRejectedValue(new Error('API Error'));
const mockGetKuduService = jest.fn().mockResolvedValue({});
const mockGetApplicationURL = jest.fn().mockResolvedValue('https://test-app.azurewebsites.net');

(AzureAppServiceUtility as jest.Mock).mockImplementation(() => ({
getAppserviceInstances: mockGetAppserviceInstances,
getKuduService: mockGetKuduService,
getApplicationURL: mockGetApplicationURL
}));

// Act
const { WebAppDeploymentProvider } = await import('../../src/DeploymentProvider/Providers/WebAppDeploymentProvider');
const provider = new WebAppDeploymentProvider(DEPLOYMENT_PROVIDER_TYPES.SPN);
await provider.PreDeploymentStep();

// Assert
expect(core.debug).toHaveBeenCalledWith(expect.stringContaining('Failed to get app service instances'));
expect(mockGetKuduService).toHaveBeenCalledWith(undefined);
});
});
});
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ branding:
color: 'blue'
runs:
using: 'node20'
main: 'lib/main.js'
main: 'dist/index.js'
File renamed without changes.
Loading
Loading