Skip to content

Commit

Permalink
dos2unix sh files
Browse files Browse the repository at this point in the history
  • Loading branch information
Brad-Edwards committed May 15, 2024
1 parent fa39a41 commit 8e8180f
Show file tree
Hide file tree
Showing 147 changed files with 27,538 additions and 27,538 deletions.
8 changes: 4 additions & 4 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
node_modules/
build/
dist/
.git/
node_modules/
build/
dist/
.git/
32 changes: 16 additions & 16 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
[flake8]
max-line-length = 120
exclude =
.git,
__pycache__,
build,
dist,
.venv,
notes,
experiment.py
ignore =
E203,
E266,
E501,
W503
per-file-ignores =
[flake8]
max-line-length = 120
exclude =
.git,
__pycache__,
build,
dist,
.venv,
notes,
experiment.py
ignore =
E203,
E266,
E501,
W503
per-file-ignores =
__init__.py: F401
12 changes: 6 additions & 6 deletions .github/actions/load-env-variables/action.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: "Load Environment Variables"
description: "Sets environment variables such as dev environment."

runs:
using: "node20"
main: "load-env-variables.js"
name: "Load Environment Variables"
description: "Sets environment variables such as dev environment."

runs:
using: "node20"
main: "load-env-variables.js"
84 changes: 42 additions & 42 deletions .github/actions/load-env-variables/load-env-variables.js
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
const core = require("@actions/core");
const github = require("@actions/github");
const fs = require("fs");

async function loadEnvironmentVariables() {
try {
const eventName = github.context.eventName;
let refName;

if (eventName === "pull_request") {
refName = github.context.payload.pull_request.base.ref;
} else if (eventName === "push") {
const refParts = github.context.ref.split("/");
refName = refParts.length > 2 ? refParts[2] : "";
} else {
throw new Error(
"Unsupported GitHub event. Only pull_request and push events are supported."
);
}

if (!["dev", "stage", "prod"].includes(refName)) {
throw new Error(
`The branch ${refName} does not map to a supported environment.`
);
}

const envName = refName.replace(/\//g, "-");
core.exportVariable("ENV_NAME", envName);

console.log(`Environment variables set for environment: ${envName}`);
} catch (error) {
core.setFailed(`Action failed with error: ${error}`);
}
}

if (require.main === module) {
loadEnvironmentVariables();
}

module.exports = {
loadEnvironmentVariables,
};
const core = require("@actions/core");
const github = require("@actions/github");
const fs = require("fs");

async function loadEnvironmentVariables() {
try {
const eventName = github.context.eventName;
let refName;

if (eventName === "pull_request") {
refName = github.context.payload.pull_request.base.ref;
} else if (eventName === "push") {
const refParts = github.context.ref.split("/");
refName = refParts.length > 2 ? refParts[2] : "";
} else {
throw new Error(
"Unsupported GitHub event. Only pull_request and push events are supported."
);
}

if (!["dev", "stage", "prod"].includes(refName)) {
throw new Error(
`The branch ${refName} does not map to a supported environment.`
);
}

const envName = refName.replace(/\//g, "-");
core.exportVariable("ENV_NAME", envName);

console.log(`Environment variables set for environment: ${envName}`);
} catch (error) {
core.setFailed(`Action failed with error: ${error}`);
}
}

if (require.main === module) {
loadEnvironmentVariables();
}

module.exports = {
loadEnvironmentVariables,
};
Original file line number Diff line number Diff line change
@@ -1,74 +1,74 @@
jest.mock('@actions/core');
const source_path = '../set-aws-credentials';
const { it } = require('@jest/globals');
const { setAwsCredentials } = require(source_path);

const core = require('@actions/core');

describe('setAwsCredentials', () => {
beforeEach(() => {
jest.clearAllMocks();

core.getInput.mockImplementation((name) => {
switch (name) {
case 'ENVIRONMENT_NAME':
return process.env['INPUT_ENVIRONMENT_NAME'];
case 'DEV_AWS_ACCESS_KEY_ID':
return 'devAccessKeyId';
case 'DEV_AWS_SECRET_ACCESS_KEY':
return 'devSecretAccessKey';
case 'PROD_AWS_ACCESS_KEY_ID':
return 'prodAccessKeyId';
case 'PROD_AWS_SECRET_ACCESS_KEY':
return 'prodSecretAccessKey';
case 'STAGE_AWS_ACCESS_KEY_ID':
return 'stageAccessKeyId';
case 'STAGE_AWS_SECRET_ACCESS_KEY':
return 'stageSecretAccessKey';
default:
return '';
}
});
});

it('should set AWS credentials for dev environment', () => {
process.env['INPUT_ENVIRONMENT_NAME'] = 'dev';

setAwsCredentials();

expect(core.setSecret).toHaveBeenCalledWith('devAccessKeyId');
expect(core.setSecret).toHaveBeenCalledWith('devSecretAccessKey');
expect(core.exportVariable).toHaveBeenCalledWith('AWS_ACCESS_KEY_ID', 'devAccessKeyId');
expect(core.exportVariable).toHaveBeenCalledWith('AWS_SECRET_ACCESS_KEY', 'devSecretAccessKey');
});

it('should set AWS credentials for prod environment', () => {
process.env['INPUT_ENVIRONMENT_NAME'] = 'prod';

setAwsCredentials();

expect(core.setSecret).toHaveBeenCalledWith('prodAccessKeyId');
expect(core.setSecret).toHaveBeenCalledWith('prodSecretAccessKey');
expect(core.exportVariable).toHaveBeenCalledWith('AWS_ACCESS_KEY_ID', 'prodAccessKeyId');
expect(core.exportVariable).toHaveBeenCalledWith('AWS_SECRET_ACCESS_KEY', 'prodSecretAccessKey');
});

it('should set AWS credentials for stage environment', () => {
process.env['INPUT_ENVIRONMENT_NAME'] = 'stage';

setAwsCredentials();

expect(core.setSecret).toHaveBeenCalledWith('stageAccessKeyId');
expect(core.setSecret).toHaveBeenCalledWith('stageSecretAccessKey');
expect(core.exportVariable).toHaveBeenCalledWith('AWS_ACCESS_KEY_ID', 'stageAccessKeyId');
expect(core.exportVariable).toHaveBeenCalledWith('AWS_SECRET_ACCESS_KEY', 'stageSecretAccessKey');
});

it('should set core.setFailed when environment name is not supported', () => {
process.env['INPUT_ENVIRONMENT_NAME'] = 'unsupported';

setAwsCredentials();

expect(core.setFailed).toHaveBeenCalledWith('Unsupported environment name: unsupported');
});
});
jest.mock('@actions/core');
const source_path = '../set-aws-credentials';
const { it } = require('@jest/globals');
const { setAwsCredentials } = require(source_path);

const core = require('@actions/core');

describe('setAwsCredentials', () => {
beforeEach(() => {
jest.clearAllMocks();

core.getInput.mockImplementation((name) => {
switch (name) {
case 'ENVIRONMENT_NAME':
return process.env['INPUT_ENVIRONMENT_NAME'];
case 'DEV_AWS_ACCESS_KEY_ID':
return 'devAccessKeyId';
case 'DEV_AWS_SECRET_ACCESS_KEY':
return 'devSecretAccessKey';
case 'PROD_AWS_ACCESS_KEY_ID':
return 'prodAccessKeyId';
case 'PROD_AWS_SECRET_ACCESS_KEY':
return 'prodSecretAccessKey';
case 'STAGE_AWS_ACCESS_KEY_ID':
return 'stageAccessKeyId';
case 'STAGE_AWS_SECRET_ACCESS_KEY':
return 'stageSecretAccessKey';
default:
return '';
}
});
});

it('should set AWS credentials for dev environment', () => {
process.env['INPUT_ENVIRONMENT_NAME'] = 'dev';

setAwsCredentials();

expect(core.setSecret).toHaveBeenCalledWith('devAccessKeyId');
expect(core.setSecret).toHaveBeenCalledWith('devSecretAccessKey');
expect(core.exportVariable).toHaveBeenCalledWith('AWS_ACCESS_KEY_ID', 'devAccessKeyId');
expect(core.exportVariable).toHaveBeenCalledWith('AWS_SECRET_ACCESS_KEY', 'devSecretAccessKey');
});

it('should set AWS credentials for prod environment', () => {
process.env['INPUT_ENVIRONMENT_NAME'] = 'prod';

setAwsCredentials();

expect(core.setSecret).toHaveBeenCalledWith('prodAccessKeyId');
expect(core.setSecret).toHaveBeenCalledWith('prodSecretAccessKey');
expect(core.exportVariable).toHaveBeenCalledWith('AWS_ACCESS_KEY_ID', 'prodAccessKeyId');
expect(core.exportVariable).toHaveBeenCalledWith('AWS_SECRET_ACCESS_KEY', 'prodSecretAccessKey');
});

it('should set AWS credentials for stage environment', () => {
process.env['INPUT_ENVIRONMENT_NAME'] = 'stage';

setAwsCredentials();

expect(core.setSecret).toHaveBeenCalledWith('stageAccessKeyId');
expect(core.setSecret).toHaveBeenCalledWith('stageSecretAccessKey');
expect(core.exportVariable).toHaveBeenCalledWith('AWS_ACCESS_KEY_ID', 'stageAccessKeyId');
expect(core.exportVariable).toHaveBeenCalledWith('AWS_SECRET_ACCESS_KEY', 'stageSecretAccessKey');
});

it('should set core.setFailed when environment name is not supported', () => {
process.env['INPUT_ENVIRONMENT_NAME'] = 'unsupported';

setAwsCredentials();

expect(core.setFailed).toHaveBeenCalledWith('Unsupported environment name: unsupported');
});
});
56 changes: 28 additions & 28 deletions .github/actions/set-aws-credentials/action.yaml
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
name: "Set AWS Credentials"
description: "Sets AWS credentials based on the provided environment name."
inputs:
DEV_AWS_ACCESS_KEY_ID:
description: "The AWS access key ID for the development environment."
required: true
DEV_AWS_SECRET_ACCESS_KEY:
description: "The AWS secret access key for the development environment."
required: true
ENVIRONMENT_NAME:
description: "The name of the environment to set the AWS credentials for."
required: true
PROD_AWS_ACCESS_KEY_ID:
description: "The AWS access key ID for the production environment."
required: true
PROD_AWS_SECRET_ACCESS_KEY:
description: "The AWS secret access key for the production environment."
required: true
STAGE_AWS_ACCESS_KEY_ID:
description: "The AWS access key ID for the staging environment."
required: true
STAGE_AWS_SECRET_ACCESS_KEY:
description: "The AWS secret access key for the staging environment."
required: true

runs:
using: "node20"
main: "set-aws-credentials.js"
name: "Set AWS Credentials"
description: "Sets AWS credentials based on the provided environment name."
inputs:
DEV_AWS_ACCESS_KEY_ID:
description: "The AWS access key ID for the development environment."
required: true
DEV_AWS_SECRET_ACCESS_KEY:
description: "The AWS secret access key for the development environment."
required: true
ENVIRONMENT_NAME:
description: "The name of the environment to set the AWS credentials for."
required: true
PROD_AWS_ACCESS_KEY_ID:
description: "The AWS access key ID for the production environment."
required: true
PROD_AWS_SECRET_ACCESS_KEY:
description: "The AWS secret access key for the production environment."
required: true
STAGE_AWS_ACCESS_KEY_ID:
description: "The AWS access key ID for the staging environment."
required: true
STAGE_AWS_SECRET_ACCESS_KEY:
description: "The AWS secret access key for the staging environment."
required: true

runs:
using: "node20"
main: "set-aws-credentials.js"
Loading

0 comments on commit 8e8180f

Please sign in to comment.