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

Automate the Config Creation Process #46

Merged
merged 14 commits into from
Nov 18, 2023

Conversation

Abby-Wheelis
Copy link
Member

@Abby-Wheelis Abby-Wheelis commented Nov 14, 2023

After some trial and error, I have begun a workflow which will automatically create a PR for new config files after someone files the templated issue form to create them.

Steps:

  1. deployer fills out a templated issue
  2. creation/update of issue launches workflow that:
    • converts the issue to a json file
    • submits a PR to add the json file to our repo
  3. TBD workflow for ensuring the PR is valid
  4. We check the PR for validity and merge into repo
    • check that it is a valid deployment (not an attack)
    • check for associated "promised" files like onboarding survey, labels, or trip survey
    • may need to do some work by hand for some custom nitty gritty (still working out form templating for trip survey or custom reminder scheme cases)

This is in an early draft stage, as I still have things to work out:

  • make sure the workflow only goes when the templated issue is filed, not a normal issue
  • ask about config fields I was unsure about
  • handle custom trip surveys
  • handle custom reminder schemes
  • set up validation (currently some degree by nature of the parsing process (won't work if things are missing), but I want to investigate testing it out)
  • write documentation for workflow and potential need to update the workflow

Related Issue

Abby Wheelis added 9 commits November 14, 2023 15:24
using this template, new deployers who are interested in working with us can fill out specifically what they want to do, in a controlled form manner -- used as input to a workflow
When an issue is created or updated, a workflow is set off that converts the templated issue into a json file, and submits it as a pr

if the issue is updated, so will the pr
adding a conditional to skip the job if it is not using the issue template
with these try/catch blocks, the goal is to catch any errors as they happen, and throw a failure message specific to that section of the process

By indicating where the problem was encountered, it should be easier to fix

The goal would be to enforce all of the controls we need through the form itself, such that people cannot submit invalid forms, but there are limitations to the issue template
@Abby-Wheelis
Copy link
Member Author

Abby-Wheelis commented Nov 16, 2023

More form updates as I practice using this in my local repo:

  • set a default of false to trip end notifications
  • set autogen and token_generate to both use the value of autogen (these need to match)

Abby Wheelis added 4 commits November 16, 2023 10:39
we've found that these notifications tend to annoy users, so it should certainly be something that must be enabled rather than something that must be enabled
these are commented out for now, as their values are hardcoded, but in case we decide to reintroduce them, fixing the formatting of these
this section will host trip and reminder scheme customization that is difficult to set up through a form -- I'm going to move forward with setting up with a form for it, but we will need to check the results against the description of what is desired more than likely
extrapolated, since they don't exist yet
Copy link
Contributor

@shankari shankari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to merge this for now so that we can see how it looks, but have some comments that can be addressed in a future PR

validations:
required: true
- type: input
id: deployment_partner_name_lang1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there no way to have this be an array instead of hardcoded lang1, lang2...? What if some programs want to have more than 2 languages? Most election material in my county, for example, has at least 4 languages - English, Spanish, Mandarin and Vietnamese.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If not, maybe we will need to create multiple templates for the number of languages

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I end up compiling it into an array, but this was the best way I found to format the template - the options are relatively limited, multiple templates could work

id: trip_survey_path
attributes:
label: Custom Trip Survey
description: Please add a path to a trip survey, something like "https://raw.githubusercontent.com/sebastianbarry/nrel-openpath-deploy-configs/surveys-info-and-surveys-data/survey-resources/data-json/trip-end-survey-multiple-select.json"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should really merge this so that the example is not in @sebastianbarry's repo
@sebastianbarry can you submit a PR?

Comment on lines +1 to +4
import { readFile } from "node:fs/promises";
import { setFailed } from "@actions/core";
import yaml from "js-yaml";

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is inspired by some other file, make sure to link it here and ensure that the LICENSE is correct

@shankari shankari merged commit a34c7f4 into e-mission:main Nov 18, 2023
@shankari
Copy link
Contributor

Note that issues were not enabled on this repo, and I had to enable them to (hopefully) get this to work.

@shankari
Copy link
Contributor

Seems to work now - I can at least create an issue...

@Abby-Wheelis
Copy link
Member Author

For the actions to run, I think you'll need to make sure that workflows are enabled and that they have permission to create pull requests

@shankari
Copy link
Contributor

shankari commented Nov 18, 2023

I am pretty sure that workflows are enabled.
https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#enabling-workflows-for-private-repository-forks

wrt enabling creation of pull requests, I think you can use the `GitHub actions token" and enable pull requests on it
https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs

Do you want to create a test issue and see what it does?

@Abby-Wheelis
Copy link
Member Author

It works! But is overzealous with the commits, I'll include a fix for that in my cleanup.

see the PR here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants