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

Split local git operations from github operations #49

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

regularfry
Copy link

Description

This patch separates out the file operations into their own command,
patch-target.sh, which is called with the relevant parameters by
entrypoint.sh.

It also makes some additions to the error handling in the
update-from-template command to make debugging a little easier.

Fixes #48.

Context

Previously the functions which identify the changes to make to the target
repository and which apply them to get a patch were intermingled with the
functions interacting with github. This meant that testing the file and
patching operations required github credentials.

Type of changes

  • Refactoring (non-breaking change)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would change existing functionality)
  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • I am familiar with the contributing guidelines
  • I have followed the code style of the project
  • I have added tests to cover my changes
  • I have updated the documentation accordingly
  • This PR is a result of pair or mob programming

Sensitive Information Declaration

To ensure the utmost confidentiality and protect your and others privacy, we kindly ask you to NOT including PII (Personal Identifiable Information) / PID (Personal Identifiable Data) or any other sensitive data in this PR (Pull Request) and the codebase changes. We will remove any PR that do contain any sensitive information. We really appreciate your cooperation in this matter.

  • I confirm that neither PII/PID nor sensitive data are included in this PR and the codebase changes.

Previously the functions which identify the changes to make to the target
repository and which apply them to get a patch were intermingled with the
functions interacting with github.  This meant that testing the file and
patching operations required github credentials.

This patch separates out the file operations into their own command,
`patch-target.sh`, which is called with the relevant parameters by
`entrypoint.sh`.

It also makes some additions to the error handling in the
`update-from-template` command to make debugging a little easier.

Fixes nhs-england-tools#48.
@@ -14,3 +14,4 @@
.docker
coverage.html
coverage.out
tmp/
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to exclude tmp/ if we have this:

temp_dir=$(mktemp -d)
trap "rm -r ${temp_dir}" EXIT

Copy link
Contributor

Choose a reason for hiding this comment

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

We probably don't want to check in the binary so may need to keep this file.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would suggest we upload the binary to the the GitHub Release asset when we have the Publish workflow complete in the repository template.

Copy link
Contributor

Choose a reason for hiding this comment

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

The following line has to be included in the Dockerfile (right after gpg.sh) for this to work as a GH Action:

COPY --from=builder /github/workspace/patch-target.sh /

Copy link
Contributor

Choose a reason for hiding this comment

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

We need to keep this file for the GH action to work.

@@ -25,7 +25,6 @@ function docker-build() {
_create-effective-dockerfile
_create-effective-version
docker build \
--progress=plain \
Copy link
Contributor

Choose a reason for hiding this comment

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

This file comes from the repository template, therefore we probably don't want to change it.

dest_dir=${2:-}
commit_msg=${3:-}
update_binary=${UPDATE_BINARY:-/update-from-template}
update_config_file=${UPDATE_CONFIG_FILE:-/.config.yaml}
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be /update-from-template.yaml rather than /.config.yaml. It is copied to the root level in the Dockerfile from the project's directory scripts/config/update-from-template.yaml.

--source-dir $src_dir \
--destination-dir $dest_dir \
--app-config-file $update_config_file \
--template-config-file $dest_dir/scripts/config/.repository-template.yaml \
Copy link
Contributor

Choose a reason for hiding this comment

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

The file name should be repository-template.yaml instead of .repository-template.yaml (no dot). The dot prefix is used when files are located at the top level directory. We don't need to do that as we store all the configuration files in the scripts/config directory.

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.

Accidental repository deletion
2 participants