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

test: check that /examples has no changes #199

Merged

Conversation

samschlegel
Copy link
Contributor

@samschlegel samschlegel commented Aug 17, 2020

Fixes #198

This will fail until something like #191 gets merged to update the examples

.travis.yml Outdated
@@ -40,3 +40,5 @@ script:
- cargo install --debug -f --path .
- cd ../
- ./smoke-test.sh
# Check that /examples has no changes
- if [ -z "$(git status --porcelain)" ]; then echo "/examples is out of date. Please run `./smoke-test.sh` locally and commit the changes"; exit 1; fi
Copy link
Collaborator

Choose a reason for hiding this comment

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

Doesn't this need to be '! -z`?

Suggested change
- if [ -z "$(git status --porcelain)" ]; then echo "/examples is out of date. Please run `./smoke-test.sh` locally and commit the changes"; exit 1; fi
- if [ ! -z "$(git status --porcelain)" ]; then echo "/examples is out of date. Please run `./smoke-test.sh` locally and commit the changes"; exit 1; fi

@UebelAndre
Copy link
Collaborator

@samschlegel I apologize for this but because of #202, master will generate some diffs in the examples. Could I get you to add the following diff to this PR?

diff --git a/impl/src/templates/remote_crates.bzl.template b/impl/src/templates/remote_crates.bzl.template
index ed0d9e8..df88ed5 100644
--- a/impl/src/templates/remote_crates.bzl.template
+++ b/impl/src/templates/remote_crates.bzl.template
@@ -17,8 +17,8 @@ def _new_git_repository(name, **kwargs):

 def {{workspace.gen_workspace_prefix}}_fetch_remote_crates():
 {%- if crates %}
-    {% for crate in crates %}
-        {%- if crate.source_details.git_data %}
+{% for crate in crates %}
+    {%- if crate.source_details.git_data %}
     _new_git_repository(
         name = "{{workspace.gen_workspace_prefix}}__{{crate.pkg_name | replace(from="-", to="_")}}__{{crate.pkg_version | slugify | replace(from="-", to="_")}}",
         remote = "{{crate.source_details.git_data.remote}}",
@@ -27,7 +27,7 @@ def {{workspace.gen_workspace_prefix}}_fetch_remote_crates():
         init_submodules = True,
         {%- include "templates/partials/remote_crates_patch.template" %}
     )
-        {%- else %}
+    {%- else %}
     _new_http_archive(
         name = "{{workspace.gen_workspace_prefix}}__{{crate.pkg_name | replace(from="-", to="_")}}__{{crate.pkg_version | slugify | replace(from="-", to="_")}}",
         url = "https://crates-io.s3-us-west-1.amazonaws.com/crates/{{crate.pkg_name}}/{{crate.pkg_name}}-{{crate.pkg_version}}.crate",
@@ -39,8 +39,8 @@ def {{workspace.gen_workspace_prefix}}_fetch_remote_crates():
         {%- include "templates/partials/remote_crates_patch.template" %}
         build_file = Label("{{workspace.workspace_path}}/remote:{{crate.pkg_name}}-{{crate.pkg_version}}.{{workspace.output_buildfile_suffix}}"),
     )
-        {%- endif %}
-    {% endfor %}
+    {%- endif %}
+{% endfor %}
 {%- else %}
     pass
 {% endif %}

I can create my own PR for this if you'd rather not. I just felt like it was a small enough change that it'd be worth making here instead of committing the diffs in the examples directory (which is only a whitespace difference)

@samschlegel
Copy link
Contributor Author

I'm not really sure what happened with the test output here... it looks like it got mixed in with a bunch of output that I'm also not sure where came from since it happened after the smoke test exited 🤔

@UebelAndre
Copy link
Collaborator

UebelAndre commented Aug 26, 2020

@samschlegel Maybe you need to rebase?

edit: I misread, I see what you're saying now. But I still think your check will fail if you don't and do something about my comment above

@samschlegel
Copy link
Contributor Author

I think it's because it was outputting to stdout and travis probably does something weird with stdout output at the end. Rebasing anyways, but don't think it's related

@UebelAndre
Copy link
Collaborator

@samschlegel Yeah, sounds likely. I have very little experience with Travis-CI though so I have to do some more digging to really help out. Hopefully your change fixes it though! 😄

@samschlegel
Copy link
Contributor Author

samschlegel commented Aug 26, 2020

Going to add a rust-toolchain file in this PR as well, since your changes in #185 use PathBuf capacity methods which weren't stabilized till 1.44 rust-lang/rust@7561714

@samschlegel
Copy link
Contributor Author

@samschlegel Maybe you need to rebase?

edit: I misread, I see what you're saying now. But I still think your check will fail if you don't and do something about my comment above

Yeah my intention is to make sure this fails correctly, then fix things and make sure it works there too. I'd like to be able to test this...but who CI's the CI‽

@samschlegel
Copy link
Contributor Author

🤦 I'm using backticks in a double-quoted string lmaoooooo

@samschlegel
Copy link
Contributor Author

andddd, that rebase did something WEIRD

@google-cla
Copy link

google-cla bot commented Aug 26, 2020

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@samschlegel samschlegel force-pushed the samschlegel/check-that-examples-has-no-changes branch from 384fa41 to c79095e Compare August 26, 2020 17:08
@UebelAndre
Copy link
Collaborator

@samschlegel Looks good but I just wanted to get clarity on this comment. Would you mind making that change as well? No worries if not, I'm just trying to cover up my shame 😅

Copy link
Collaborator

@UebelAndre UebelAndre left a comment

Choose a reason for hiding this comment

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

LGTM! 🚀

@UebelAndre
Copy link
Collaborator

@damienmg @dfreese Could someone with merge powers take a look at this pull-request?

Copy link
Member

@damienmg damienmg left a comment

Choose a reason for hiding this comment

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

I just have a minor comment, there seems to be an unwanted edit in this PR.

impl/src/templates/remote_crates.bzl.template Outdated Show resolved Hide resolved
@damienmg damienmg merged commit 7b63f24 into google:master Aug 27, 2020
@damienmg
Copy link
Member

Thanks!

damienmg pushed a commit that referenced this pull request Aug 28, 2020
…r defects. (#207)

This is a followup on comments made in #199 

The `crates.bzl` file generated in the event that no crates are defined looks like the following
```python
"""
@generated
cargo-raze crate workspace functions

DO NOT EDIT! Replaced on runs of cargo-raze
"""

load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository")  # buildifier: disable=load
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")  # buildifier: disable=load
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")  # buildifier: disable=load

def raze_fetch_remote_crates():
    """No crates were detected in the source Cargo.toml. This is a no-op"""
    pass
```
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.

Add CI check to ensure /examples directory is kept up to date.
3 participants