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

feat: add master merge support #5

Merged
merged 4 commits into from
Oct 31, 2023
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 11 additions & 33 deletions .github.jsonnet
Original file line number Diff line number Diff line change
@@ -1,38 +1,16 @@
local util = import './.github/jsonnet/index.jsonnet';
local image = 'eu.gcr.io/unicorn-985/docker-images_node14-with-libnss:deploy-5893c6fca68ea35a0a51e855d5a3cb7082ef39fa';

util.pipeline(
local testJob = util.ghJob(
'test-pr',
[
util.ghJob(
'test-pr',
image=image,
useCredentials=true,
steps=[
util.checkoutAndYarn(ref='${{ github.event.pull_request.head.sha }}', fullClone=false),
util.action('setup chrome', 'browser-actions/setup-chrome@latest'),
util.step('test', './node_modules/.bin/ember test'),
util.yarnPublish(isPr=true),
],
runsOn=['ubuntu-latest'], // it's public fork. don't use private runners for public fork
),
image=image,
useCredentials=true,
steps=[
util.checkoutAndYarn(ref='${{ github.event.pull_request.head.sha }}', fullClone=false),
util.action('setup chrome', 'browser-actions/setup-chrome@latest'),
util.step('test', './node_modules/.bin/ember test'),
],
) +
util.pipeline(
'publish-tag',
[
util.ghJob(
'publish',
image=image,
useCredentials=true,
steps=[
util.checkoutAndYarn(ref='${{ github.sha }}', fullClone=false),
util.yarnPublish(isPr=false),
],
runsOn=['ubuntu-latest'], // it's public fork. don't use private runners for public fork
),
],
event={
push: { tags: ['*'] },
},
)
runsOn=['ubuntu-latest'], // it's public fork. don't use private runners for public fork
);

util.workflowJavascriptPackage(testJob=testJob)
2 changes: 1 addition & 1 deletion .github/jsonnet/GIT_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
497456f307c7f9ef1d9ac1660b951b1cf8a6e024
9f0090f332fe3306ec145c60d2e129628aee2f9c
88 changes: 59 additions & 29 deletions .github/jsonnet/base.jsonnet
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
{
pipeline(name, jobs, event = 'pull_request', permissions = null):: {
pipeline(name, jobs, event=['pull_request'], permissions=null, concurrency=null):: {
[name + '.yml']:
std.manifestYamlDoc(
{
name: name,
on: event,
jobs: std.foldl(function(x, y) x + y, jobs, {}),
} + (if permissions == null then {} else {permissions: permissions}),
),
} + (if permissions == null then {} else { permissions: permissions }) + (if concurrency == null then {} else { concurrency: concurrency }),
),
},

ghJob(name,
ghJob(
name,
timeoutMinutes=30,
runsOn=null,
image=$.default_job_image,
Expand All @@ -20,40 +21,69 @@
outputs=null,
useCredentials=true,
services=null,
permissions=null,
concurrency=null,
continueOnError=null,
)::
{
[name]: {
'timeout-minutes': timeoutMinutes,
'runs-on': (if runsOn == null then ['self-hosted', 'runner-2'] else runsOn),
container: {
image: image,
} + (if useCredentials then { credentials: { username: '_json_key', password: $.secret('docker_gcr_io') }} else {})
,
steps: std.flattenArrays(steps),
} +
(if ifClause != null then {'if': ifClause} else {}) +
(if needs != null then {'needs': needs} else {}) +
(if outputs != null then {'outputs': outputs} else {}) +
(if services != null then {'services': services} else {})
},
{
[name]: {
'timeout-minutes': timeoutMinutes,
'runs-on': (if runsOn == null then ['self-hosted', 'runner-2'] else runsOn),
} +
(
if image == null then {} else
{
container: {
image: image,
} + (if useCredentials then { credentials: { username: '_json_key', password: $.secret('docker_gcr_io') } } else {}),
}
) +
{
steps: std.flattenArrays(steps),
} +
(if ifClause != null then { 'if': ifClause } else {}) +
(if needs != null then { needs: needs } else {}) +
(if outputs != null then { outputs: outputs } else {}) +
(if services != null then { services: services } else {}) +
(if permissions == null then {} else { permissions: permissions }) +
(if concurrency == null then {} else { concurrency: concurrency }) +
(if continueOnError == null then {} else { 'continue-on-error': continueOnError }),
},

ghExternalJob(
name,
uses,
with=null,
)::
{
[name]: {
uses: uses,
} + (if with != null then {
with: with,
} else {}),
},

step(name, run, env=null, workingDirectory=null, ifClause=null, id=null)::
[{
name: name,
run: run,
} + (if workingDirectory != null then { 'working-directory': workingDirectory } else { })
step(name, run, env=null, workingDirectory=null, ifClause=null, id=null, continueOnError=null)::
[
{
name: name,
run: run,
} + (if workingDirectory != null then { 'working-directory': workingDirectory } else {})
+ (if env != null then { env: env } else {})
+ (if ifClause != null then { 'if': ifClause } else {})
+ (if id != null then { id: id } else {})
+ (if continueOnError == null then {} else { 'continue-on-error': continueOnError }),
],

action(name, uses, env=null, with=null, id=null, ifClause=null)::
[{
name: name,
uses: uses,
} + (if env != null then { env: env } else {})
action(name, uses, env=null, with=null, id=null, ifClause=null, continueOnError=null)::
[
{
name: name,
uses: uses,
} + (if env != null then { env: env } else {})
+ (if with != null && with != {} then { with: with } else {})
+ (if id != null then { id: id } else {})
+ (if ifClause != null then { 'if': ifClause } else {})
+ (if continueOnError == null then {} else { 'continue-on-error': continueOnError }),
],
}
11 changes: 9 additions & 2 deletions .github/jsonnet/clusters.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
name: 'prod-europe-west4',
zone: 'europe-west4',
secret: '${{ secrets.GCE_JSON }}',
}
}
},

'gynzy-intern': {
project: 'gynzy-intern',
name: 'gynzy-intern',
zone: 'europe-west4',
secret: '${{ secrets.CONTINUOUS_DEPLOYMENT_GCE_JSON }}',
},
},
}
31 changes: 31 additions & 0 deletions .github/jsonnet/complete-workflows.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
/*
@param {string[]} repositories - The repositories to publish to
@param {boolean} isPublicFork - Whether the repository is a public fork
@param {boolean} checkVersionBump - Whether to assert if the version was bumped (recommended)
@param {ghJob} testJob - a job to be ran during PR to assert tests. can be an array of jobs
*/
workflowJavascriptPackage(repositories=['gynzy'], isPublicFork=true, checkVersionBump=true, testJob=null)::
local runsOn = (if isPublicFork then 'ubuntu-latest' else null);

$.pipeline(
'misc',
[$.verifyJsonnet(fetch_upstream=false, runsOn=runsOn)],
) +
$.pipeline(
'publish-prod',
[
$.yarnPublishJob(repositories, runsOn=runsOn),
],
event={ push: { branches: ['${{ github.event.pull_request.base.ref }}'] } },
) +
$.pipeline(
'pr',
[
$.yarnPublishPreviewJob(repositories=repositories, runsOn=runsOn, checkVersionBump=checkVersionBump),
] +
(if testJob != null then
[testJob]
else [])
),
}
144 changes: 87 additions & 57 deletions .github/jsonnet/databases.jsonnet
Original file line number Diff line number Diff line change
@@ -1,76 +1,106 @@
{
database_servers: {
test: {
server: 'test-ams',
region: 'europe-west4',
project: 'unicorn-985',
},
'test-ams-8': {
server: 'test-ams-8',
region: 'europe-west4',
project: 'unicorn-985',
},
'eu-w4-unicorn-production': {
server: 'eu-w4-unicorn-production',
region: 'europe-west4',
project: 'unicorn-985',
},
'eu-w4-responses-production' : {
server: 'eu-w4-responses-production',
region: 'europe-west4',
project: 'unicorn-985',
},
'eu-w4-metrics-production' : {
server: 'eu-w4-metrics-production',
region: 'europe-west4',
project: 'unicorn-985',
},
'gynzy-test' : {
server: 'gynzy-test',
region: 'europe-west4',
project: 'gynzy-1090',
},
'gynzy-production' : {
server: 'gynzy-production',
region: 'europe-west4',
project: 'gynzy-1090',
},
'accounts-production': {
server: 'eu-w4-accounts-production',
region: 'europe-west4',
project: 'unicorn-985',
},
'eu-w4-licenses-v8' : {
server: 'eu-w4-licenses-v8',
region: 'europe-west4',
project: 'unicorn-985',
},
'eu-w4-curriculum-v8': {
server: 'eu-w4-curriculum-v8',
region: 'europe-west4',
project: 'unicorn-985',
}
test: {
type: 'mysql',
server: 'test-ams',
region: 'europe-west4',
project: 'unicorn-985',
lifecycle: 'test',
},
'test-ams-8': {
type: 'mysql',
server: 'test-ams-8',
region: 'europe-west4',
project: 'unicorn-985',
lifecycle: 'test',
},
'eu-w4-unicorn-production': {
type: 'mysql',
server: 'eu-w4-unicorn-production',
region: 'europe-west4',
project: 'unicorn-985',
},
'eu-w4-responses-production': {
type: 'mysql',
server: 'eu-w4-responses-production',
region: 'europe-west4',
project: 'unicorn-985',
},
'eu-w4-metrics-production': {
type: 'mysql',
server: 'eu-w4-metrics-production',
region: 'europe-west4',
project: 'unicorn-985',
},
'gynzy-test': {
type: 'mysql',
server: 'gynzy-test',
region: 'europe-west4',
project: 'gynzy-1090',
lifecycle: 'test',
},
'gynzy-production': {
type: 'mysql',
server: 'gynzy-production',
region: 'europe-west4',
project: 'gynzy-1090',
},
'accounts-production': {
type: 'mysql',
server: 'eu-w4-accounts-production',
region: 'europe-west4',
project: 'unicorn-985',
},
'eu-w4-licenses-v8': {
type: 'mysql',
server: 'eu-w4-licenses-v8',
region: 'europe-west4',
project: 'unicorn-985',
},
'eu-w4-curriculum-v8': {
type: 'mysql',
server: 'eu-w4-curriculum-v8',
region: 'europe-west4',
project: 'unicorn-985',
},
'eu-w4-enrollments-v8': {
type: 'mysql',
server: 'eu-w4-enrollments-v8',
region: 'europe-west4',
project: 'unicorn-985',
},
'eu-w4-board-v8': {
type: 'mysql',
server: 'eu-w4-board-v8',
region: 'europe-west4',
project: 'unicorn-985',
},

},

copyDatabase(mysqlActionOptions)::
assert std.length(std.findSubstr('_pr_', mysqlActionOptions.database_name_target)) > 0; // target db gets deleted. must contain _pr_
assert std.length(std.findSubstr('_pr_', mysqlActionOptions.database_name_target)) > 0; // target db gets deleted. must contain _pr_

// overwrite and set task to clone
// delete database by setting it to null and calling prune afterwards
local pluginOptions = std.prune(mysqlActionOptions + { task: 'clone', database: null });
local pluginOptions = std.prune(mysqlActionOptions { task: 'clone', database: null });

$.action('copy-database', $.mysql_action_image,
$.action(
'copy-database',
$.mysql_action_image,
with=pluginOptions
),

deleteDatabase(mysqlActionOptions)::
assert std.length(std.findSubstr('_pr_', mysqlActionOptions.database_name_target)) > 0; // this fn deletes the database. destination db must contain _pr_
assert std.length(std.findSubstr('_pr_', mysqlActionOptions.database_name_target)) > 0; // this fn deletes the database. destination db must contain _pr_

// overwrite and set task to clone
// delete database by setting it to null and calling prune afterwards
local pluginOptions = std.prune(mysqlActionOptions + { task: 'remove', database: null });
local pluginOptions = std.prune(mysqlActionOptions { task: 'remove', database: null });

$.action('delete-database', $.mysql_action_image,
$.action(
'delete-database',
$.mysql_action_image,
with=pluginOptions
),
}
}
Loading