Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add autodeploy when pushing to prod #428

Merged
merged 4 commits into from
Oct 3, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
36 changes: 27 additions & 9 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ steps:
when:
event:
- push
- pull_request
commands:
- yarn
depends_on:
Expand All @@ -20,7 +19,6 @@ steps:
when:
event:
- push
- pull_request
depends_on:
- setup
commands:
Expand All @@ -31,7 +29,6 @@ steps:
when:
event:
- push
- pull_request
depends_on:
- setup
commands:
Expand All @@ -41,7 +38,7 @@ steps:
image: node:14
when:
event:
- pull_request
- push
depends_on:
- test
commands:
Expand All @@ -58,7 +55,6 @@ steps:
when:
event:
- push
- pull_request
branch:
exclude: [prod]
depends_on:
Expand All @@ -67,15 +63,14 @@ steps:
- yarn build

- name: protractor
image: circleci/node:14-browsers
image: circleci/node:16-browsers
# We run as root, because the docker daemon
# no-new-priviliges flag
# prohibits us from running sudo
user: root
when:
event:
- push
- pull_request
depends_on:
- setup
commands:
Expand All @@ -92,7 +87,7 @@ steps:
image: plugins/docker
when:
branch:
- build
- prod
event: push
status: success
depends_on:
Expand All @@ -112,6 +107,29 @@ steps:
build_args:
- RELEASE=version-${DRONE_COMMIT_SHA:0:7}

- name: Deploy
image: abakus/ansible-deploy
when:
branch:
- prod
event: push
status: success
depends_on:
- docker
settings:
playbook: /infrastructure/esas/playbooks/deploy.yml
repository:
from_secret: infra_repository
tags:
- vote
limit: esas
extra_vars: vote_version=version-${DRONE_COMMIT_SHA:0:7}
inventory: /infrastructure/inventory
vault_password:
from_secret: ansible_vault_password
private_key:
from_secret: infra_deploy_key

services:
- name: mongodb
image: mongo:4.4
Expand All @@ -121,4 +139,4 @@ services:

---
kind: signature
hmac: 7b739c5ad6e81bd59b8b64fa5484095cc4dec4b030acd7a62263abd6f8b63b25
hmac: 29a1a3d0c44d50ddb78ad36fcb911dbd4a90cce0077ee335402c61d90ad7c011
8 changes: 7 additions & 1 deletion features/step_definitions/webSteps.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,33 @@ function logIn(username, password) {
module.exports = function () {
this.Given(/^I am logged in as an admin$/, () => {
logIn('admin', 'password');
this.userType = 'admin';
});

this.Given(/^I am logged in as a moderator$/, () => {
logIn('moderator', 'password');
this.userType = 'moderator';
});

this.When(/^I log in$/, () => {
logIn('testUser', 'password');
this.userType = 'user';
});

this.When(/^I log out/, () => {
const logoutButton = element(by.linkText('Logg ut'));
logoutButton.click();
this.userType = undefined;
});

this.Given(/^I am logged in$/, () => {
logIn('testUser', 'password');
});

this.Given(/^I am on page "([^"]*)"$/, (path) => {
browser.get(path);
const actualPath =
this.userType === 'moderator' ? path + '?dummyReader' : path;
browser.get(actualPath);
});

this.When(/^I go to page "([^"]*)"$/, (path) => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"prettier": "prettier '**/*.{js,ts,pug}' --write",
"mocha": "NODE_ENV=test MONGO_URL=${MONGO_URL:-'mongodb://localhost:27017/vote-test'} nyc mocha test/**/*.test.js --exit --timeout 30000",
"coverage": "nyc report --reporter=text-lcov | coveralls",
"protractor": "webdriver-manager update --standalone false --versions.chrome 86.0.4240.22 && NODE_ENV=protractor MONGO_URL=${MONGO_URL:-'mongodb://localhost:27017/vote-test'} protractor ./features/protractor-conf.js",
"protractor": "webdriver-manager update --standalone false --versions.chrome 93.0.4577.82 && NODE_ENV=protractor MONGO_URL=${MONGO_URL:-'mongodb://localhost:27017/vote-test'} protractor ./features/protractor-conf.js",
"postinstall": "yarn build"
},
"prettier": {
Expand Down