Skip to content

50 run tests requiring a bitbucket server in GitHub actions #52

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

Merged

Conversation

jesperes
Copy link
Contributor

This is a rather large PR which adds support for running the PropEr tests in prop_api.erl and prop_yml.erl. These tests require a running Bitbucket Server instance, which is the reason these have not been run before. This also caused problems because PRs opened against the GitHub repo were not being tested properly. (These tests were only run internally at Klarna.)

To spin up a Bitbucket Server instance, the build.yml workflow has been modified to start a Bitbucket service using the atlassian/bitbucket-server:7.17.1 Docker image. It uses a "time-bomb" license retrieved from here which will automatically expire after three hours.

There is also a docker-compose setup in scripts/pre-test-hook.sh which is invoked automatically when running rebar3 proper locally. (Currently, to run these tests locally, you must use the run-tests-with-bb.sh script, but I hope to fix so that won't be necessary, and users should be able to just run rebar3 proper to test things, and things should "just work".

@jesperes jesperes requested a review from a team as a code owner September 12, 2022 08:20
@jesperes jesperes linked an issue Sep 12, 2022 that may be closed by this pull request
@jesperes jesperes force-pushed the 50-run-tests-requiring-a-bitbucket-server-in-github-actions branch from 3674a87 to 49d8d26 Compare September 12, 2022 08:25
@jesperes
Copy link
Contributor Author

Caveat: the workzone and hook tests will not be run, since these require additional plugins installed in Bitbucket.

@@ -0,0 +1,13 @@
#!/bin/bash
Copy link
Member

Choose a reason for hiding this comment

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

nit: #!/bin/sh suffices here

LocalRepo = "/tmp/bec-test" ++ integer_to_list(rand:uniform(1 bsl 127)),
ok = cmd("mkdir -p ~s && cd ~s && "
"git init . && "
"git config user.email $USER@$HOSTNAME && "
Copy link
Member

Choose a reason for hiding this comment

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

nit: shouldn't these be hard-coded to something innocous like jane.doe@example.com?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Perhaps, but the repo is extremely shortlived (it is deleted in the same shell command). It only exists in order to populate the repository with a branch/commit.

init_repo()
catch C:T:St ->
%% If the setup function fails, the teardown function is not
%% executed and we risk leaving a running bitbucket instance in a
Copy link
Member

Choose a reason for hiding this comment

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

nit: an inconsistent state


cmd(Fmt, Args) ->
Cmd = lists:flatten(io_lib:format(Fmt, Args)),
%% TODO log command output somewhere
Copy link
Member

Choose a reason for hiding this comment

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

you're enabling lager so why not that?

@@ -423,18 +442,25 @@ setup() ->
application:set_env(bec, bitbucket_username, Username),
application:set_env(bec, bitbucket_password, Password),
{ok, Started} = application:ensure_all_started(bec),
#{started => Started}.
bec_test_utils:init_bitbucket(),
bec_test_utils:init_logging(),
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if logging shouldn't be enabled first, and perhaps even be baked into init_bitbucket/0.

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 plan to rip out lager and replace it with logger to get rid of an unnecessary dependency. I'll take care of this feedback then.

@jesperes jesperes merged commit 1306587 into master Sep 12, 2022
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.

Run tests requiring a Bitbucket Server in GitHub Actions
2 participants