Skip to content

Commit

Permalink
feat(github-actions): support isDeployable flag
Browse files Browse the repository at this point in the history
  • Loading branch information
mildronize committed May 6, 2024
1 parent 3c5b9b6 commit 0f73841
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,23 @@ jobs:

- name: Azure Login
uses: azure/login@v2
if: matrix.is_deployable == true
with:
creds: ${{ secrets.AZURE_CREDENTIALS_E2E_TESTS }}

- name: Deploy to Azure Functions
uses: Azure/functions-action@v1
if: matrix.is_deployable == true
with:
app-name: nmt-e2e-${{ matrix.target }}-${{ secrets[matrix.resource_identifier_key] }}
package: examples/with-${{ matrix.runtime }}/.nmt/dist

- name: Wait for the deployment to finish
if: matrix.is_deployable == true
run: sleep 15

- name: Run E2E tests
if: matrix.is_deployable == true
run: pnpm exec nx run @infra/azure-functions:test
env:
AZURE_FUNCTIONS_URL: https://nmt-e2e-${{ matrix.target }}-${{ secrets[matrix.resource_identifier_key] }}.azurewebsites.net
Expand Down
19 changes: 13 additions & 6 deletions infra/azure-functions/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,25 @@ export const infraConfigs = createInfraConfig(
'node18-win-x64': process.env.RESOURCE_IDENTIFIER_NODE18_WIN_X64,
},
[
// --- Node 18 ---
{
platform: 'linux',
arch: 'x64',
runtime: 'node18',
isDeployable: true,
},
// {
// platform: 'win',
// arch: 'x64',
// runtime: 'node18',
// isDeployable: true,
// },
{
platform: 'win',
arch: 'x64',
runtime: 'node18',
// isDeployable: true,
},
{
platform: 'macos',
arch: 'arm64',
runtime: 'node18',
},
// --- Bun ----
// {
// platform: 'linux',
// arch: 'x64',
Expand Down
5 changes: 5 additions & 0 deletions infra/azure-functions/src/github-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ export interface GithubActionsMatrix {
* Resource Identifier Key for getting value from github actions secrets
*/
resource_identifier_key: string;
/**
* is deployable
*/
is_deployable?: boolean;
}

/**
Expand Down Expand Up @@ -51,6 +55,7 @@ export function toGithubActionsMatrix(configs: InfraEnvConfig[]): GithubActionsM
runtime: runtime === 'bun' ? 'bun' : 'node',
version,
target: toTarget(config),
is_deployable: config.isDeployable,
resource_identifier_key: `RESOURCE_IDENTIFIER_${toTarget(config).replaceAll('-', '_').toUpperCase()}`,
} satisfies GithubActionsMatrix;
});
Expand Down
2 changes: 1 addition & 1 deletion infra/azure-functions/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ export function createInfraConfig(
infraConfigs: InfraEnvConfig[]
): InfraEnvConfig[] {
return infraConfigs
.filter(config => config.isDeployable)
.map(infraConfig => {
const resourceIdentifier: string =
resourceIdentifiers[toTarget(infraConfig)] ?? fallbackResourceIdentifier(infraConfig);

return {
...infraConfig,
isDeployable: infraConfig.isDeployable ?? false,
resourceIdentifier,
};
});
Expand Down

0 comments on commit 0f73841

Please sign in to comment.