Skip to content
This repository has been archived by the owner on Jul 27, 2023. It is now read-only.

Handle test assets without submodules and extra setup #180

Closed
wants to merge 9 commits into from

Conversation

uint
Copy link
Contributor

@uint uint commented Apr 19, 2021

This is part of the work for #176, but not all of it. It's just my proposal! We can scrap it if it doesn't work for you.

How it works

git-platinum is now kept as a tarball in data/git-platinum.tgz. All the necessary refs are in there already. There's a build.rs script that extracts the archive into data/git-platinum, which is ignored by git (git doesn't like nested repos, so we don't want to try checking it in).

Updating git-platinum

There's a script for that - scripts/update-git-platinum.sh. It will fetch the newest version of git-platinum, add the necessary refs, then update and commit the archive.

The big win

It should now be possible to simply git clone the repo and run cargo test without extra setup necessary, keeping it simple for future contributors. Also no more submodules.

Drawbacks

  • 2 build dependencies added - flate2 and tar.
  • The build script doesn't distinguish between test builds and other builds. It will unpack the archive even if we're not running any tests. Any errors there will stop the build.

@FintanH
Copy link
Collaborator

FintanH commented Apr 21, 2021

The build script doesn't distinguish between test builds and other builds. It will unpack the archive even if we're not running any tests. Any errors there will stop the build.

I thought we might have been able to use:

if cfg!(test) {
  unpack
  println!
}

But it seems like the build.rs file doesn't know about cargo test being run and so it never fires. Not a big deal anyway since it'll only run once unless the tar file is changed. If it fails the person won't be able to run the tests which would be bad anyway and they should report an issue.

Copy link
Collaborator

@FintanH FintanH 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 in favour of this! What would the rest of the work look like? :)

scripts/update-git-platinum.sh Outdated Show resolved Hide resolved
@uint
Copy link
Contributor Author

uint commented Apr 21, 2021

I'm in favour of this! What would the rest of the work look like? :)

Oh, I was referring to actually reorganizing the tests - as you wanted to in #176. No idea yet!

@uint
Copy link
Contributor Author

uint commented Apr 21, 2021

Rebased and added sign-offs.

Copy link
Collaborator

@FintanH FintanH left a comment

Choose a reason for hiding this comment

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

Just a few things to clean up and then this is good to be merged :)

@@ -11,5 +11,5 @@ while IFS= read -r line
do
Copy link
Collaborator

Choose a reason for hiding this comment

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

We don't need this file anymore, right? We just use the same logic in the update script afaict. Would you mind removing this if that's the case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, I meant to do that! Probably forgot. I'll add the change shortly.

data/README.md Outdated Show resolved Hide resolved

# This is here in case the last script run failed and it never cleaned up.
# Is there a better way to handle this?
rm -rf git-platinum
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe a safer thing to do here is checking if the directory exists and asking the person to remove it and exiting the script.

I'm worried that we'd remove a git-platinum by accident, e.g. we ran the script in the wrong directory 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What if the whole script worked in some sort of .workdir and we added that one to .gitignore?

Copy link
Collaborator

Choose a reason for hiding this comment

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

#180 (comment) would be enough to resolve this I think :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I still created a sort of workdir. Feels cleaner anyway. How's that look?

set -euo pipefail

## This is an update script for /data/git-platinum. It's meant to be executed
## from the root of the repo.
Copy link
Collaborator

Choose a reason for hiding this comment

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

We could check that we're at the root by doing:

BASE=$(basename pwd)

if [ "${BASE}" -ne "radicle-surf" ]
then
   echo "this script should be run from the root of radicle-surf"
   exit 1
fi

Or something along those lines :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's excellent. I'll give it a try. I was wondering if that's possible, but my bash powers are honestly fairly weak ;)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Mine aren't much better, but I sure can google! :P

@@ -11,8 +11,8 @@ Alongside this, we will wish to take two snapshots and view their differences.

## Contributing

To get started on contributing you can check out our [developing guide](./DEVELOPMENT.md), and also
our [LICENSE](./LICENSE) file.
To get started on contributing you can check out our [developing guide](../DEVELOPMENT.md), and also
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for catching these :)

FintanH
FintanH previously approved these changes Apr 22, 2021
Copy link
Collaborator

@FintanH FintanH left a comment

Choose a reason for hiding this comment

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

Looks good! Just some small suggestions and then we're really ready to merge :)

data/README.md Outdated Show resolved Hide resolved
scripts/update-git-platinum.sh Outdated Show resolved Hide resolved
Signed-off-by: Tomasz Kurcz <[email protected]>

Co-authored-by: Fintan Halpenny <[email protected]>
@FintanH
Copy link
Collaborator

FintanH commented Apr 22, 2021

Merged via f238a45

@FintanH FintanH closed this Apr 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants