Skip to content

Commit

Permalink
Merge pull request #38 from AppQuality/develop
Browse files Browse the repository at this point in the history
release-2022-04-27
  • Loading branch information
sinatragianpaolo authored Apr 27, 2022
2 parents b491ada + 8d7a51e commit cba60dd
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 91 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ jobs:
needs: push-to-ecr
runs-on: ubuntu-latest
environment: preproduction
outputs:
original_preprod_desired: ${{ steps.update-asg.outputs.original_desired }}
original_preprod_max: ${{ steps.update-asg.outputs.original_max }}
steps:
- name: Checkout
uses: actions/checkout@v2
Expand Down Expand Up @@ -71,6 +74,16 @@ jobs:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-west-1
- name: Update asg capacity to 1
uses: AppQuality/update-desired-asg-instances@v1.0.0
id: update-asg
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: "eu-west-1"
ASG_NAME: crowd-api-asg-preproduction
DESIRED_INSTANCES: 1
MAX_INSTANCES: 1
- name: Start CodePipeline
uses: moia-oss/aws-codepipeline-trigger@v1
with:
Expand Down Expand Up @@ -113,11 +126,30 @@ jobs:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-west-1
- name: Update asg capacity to 2
uses: AppQuality/update-desired-asg-instances@v1.0.0
id: update-asg
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: "eu-west-1"
ASG_NAME: crowd-api-asg-production
DESIRED_INSTANCES: 2
MAX_INSTANCES: 2
- name: Start CodePipeline
uses: moia-oss/aws-codepipeline-trigger@v1
with:
pipeline: crowd-api-app-production-code-pipeline
wait: true
- name: Restore asg capacity
uses: AppQuality/update-desired-asg-instances@v1.0.0
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: "eu-west-1"
ASG_NAME: crowd-api-asg-production
DESIRED_INSTANCES: ${{ steps.update-asg.outputs.original_desired }}
MAX_INSTANCES: ${{ steps.update-asg.outputs.original_max }}
- name: Get deployment url
uses: AppQuality/get-codeploy-from-codepipeline@1.0.0
id: codedeploy
Expand All @@ -133,3 +165,18 @@ jobs:
with:
body: "[![](https://img.shields.io/badge/AWS-Redeploy-blueviolet)](${{ steps.codedeploy.outputs.codedeploy_url }})"
isAppendBody: true
disable-preprod-on-release:
name: Disable PreProd
needs: [prepare-release-for-prod, release-to-preprod]
runs-on: ubuntu-latest
environment: preproduction
steps:
- name: Restore asg capacity
uses: AppQuality/update-desired-asg-instances@v1.0.0
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: "eu-west-1"
ASG_NAME: crowd-api-asg-preproduction
DESIRED_INSTANCES: ${{needs.release-to-preprod.outputs.original_preprod_desired }}
MAX_INSTANCES: ${{needs.release-to-preprod.outputs.original_preprod_max }}
94 changes: 6 additions & 88 deletions src/__mocks__/mockedDb/campaign.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,106 +4,24 @@ export const table = {
create: async () => {
await sqlite3.createTable("wp_appq_evd_campaign", [
"id INTEGER(11) PRIMARY KEY",
"title VARCHAR(256) NOT NULL",
"description VARCHAR(512)",
"platform_id INTEGER(11) NOT NULL",
"start_date DATETIME NOT NULL",
"end_date DATETIME NOT NULL",
"close_date DATETIME",
"desired_number_of_testers INTEGER(4) DEFAULT 20",
"customer VARCHAR(45)",
"platform_version INTEGER(11)",
"test_fairy_project VARCHAR(45)",
"test_fairy_build VARCHAR(45)",
"jot_form_prj VARCHAR(45)",
"base_bug_internal_id VARCHAR(45)",
"number_of_test_case INTEGER(2)",
"status_id INTEGER(1) DEFAULT 1",
"is_public INTEGER(1) DEFAULT 0",
"manual_link VARCHAR(256)",
"preview_link VARCHAR(256)",
"page_preview_id INTEGER(20) NOT NULL",
"page_manual_id INTEGER(20) NOT NULL",
"campaign_type INTEGER(1) DEFAULT 0",
"os VARCHAR(3000) DEFAULT 0",
"form_factor VARCHAR(3000) DEFAULT 0",
"low_bug_pts INTEGER(1) NOT NULL DEFAULT 0",
"medium_bug_pts INTEGER(1) NOT NULL DEFAULT 0",
"high_bug_pts INTEGER(1) NOT NULL DEFAULT 0",
"critical_bug_pts INTEGER(1) NOT NULL DEFAULT 0",
"campaign_pts INTEGER(1) NOT NULL DEFAULT 200",
"customer_id INTEGER(11) NOT NULL",
"pm_id INTEGER(11) NOT NULL",
"custom_link VARCHAR(256)",
"min_allowed_media INTEGER(11) NOT NULL DEFAULT 3",
"campaign_type_id INTEGER(11) DEFAULT 0",
"project_id INTEGER(11) NOT NULL",
"customer_title VARCHAR(256) NOT NULL",
"screen_on_every_step INTEGER(2) NOT NULL DEFAULT 0",
"tb_link VARCHAR(2048)",
"cust_bug_vis INTEGER(1) NOT NULL DEFAULT 0",
"bug_lang INTEGER(1) DEFAULT 0",
"aq_index FLOAT NOT NULL DEFAULT 1",
"effort FLOAT",
"tokens_usage FLOAT",
"ux_effort FLOAT",
]);
},
drop: async () => {
await sqlite3.dropTable("wp_appq_evd_campaign");
},
};

type CampaignParams = {
id?: number;
};
const data: {
[key: string]: (params?: any) => Promise<{ [key: string]: any }>;
[key: string]: (params?: CampaignParams) => Promise<{ [key: string]: any }>;
} = {};

data.runningCp = async () => {
data.basicCampaign = async (params) => {
const item = {
id: 1,
title: "Running Campaign",
description: "",
platform_id: 1,
start_date: new Date("01/01/2021").toISOString(),
end_date: new Date("01/01/2021").toISOString(),
close_date: new Date("01/01/2021").toISOString(),
desired_number_of_testers: 20,
customer: "",
platform_version: 0,
test_fairy_project: "",
test_fairy_build: "",
jot_form_prj: "",
base_bug_internal_id: "",
number_of_test_case: 0,
status_id: 1,
is_public: 0,
manual_link: "",
preview_link: "",
page_preview_id: 0,
page_manual_id: 0,
campaign_type: 0,
os: "",
form_factor: "",
low_bug_pts: 0,
medium_bug_pts: 0,
high_bug_pts: 0,
critical_bug_pts: 0,
campaign_pts: 200,
customer_id: 0,
pm_id: 0,
custom_link: "",
min_allowed_media: 3,
campaign_type_id: 0,
project_id: 0,
customer_title: "",
screen_on_every_step: 0,
tb_link: "",
cust_bug_vis: 0,
bug_lang: 0,
aq_index: 1,
effort: 0,
tokens_usage: 0,
ux_effort: 0,
...params,
};
await sqlite3.insert("wp_appq_evd_campaign", item);
return item;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import app from "@src/app";
import sqlite3 from "@src/features/sqlite";
import {
data as cpData,
table as cpTable,
Expand All @@ -14,8 +16,6 @@ import {
data as wpUsersData,
table as wpUsersTable,
} from "@src/__mocks__/mockedDb/wp_users";
import app from "@src/app";
import sqlite3 from "@src/features/sqlite";
import request from "supertest";

jest.mock("@src/features/db");
Expand All @@ -24,7 +24,7 @@ describe("POST /campaigns/{campaignId}/candidates", () => {
beforeEach(async () => {
return new Promise(async (resolve) => {
await cpTable.create();
await cpData.runningCp();
await cpData.basicCampaign();
await testerTable.create();
await testerData.testerWithBooty();
await wpUsersTable.create();
Expand Down

0 comments on commit cba60dd

Please sign in to comment.