Anvil IDE Semi-Continuous Integration

I recently started having some quick tests run automatically any time I run a “Debug” session of my app, which I generally try to do before each commit. So I guess that counts as semi-automatic testing, though it’s slightly short of continuous integration of tests.

This app demonstrates the idea:
https://anvil.works/build#clone:5ZOEKPZOJLPYLN64=AEVUAWTVM7EFLSY6IUORZ675

The unittest module on the server (or why not use pytest?) provides nicer output than the limited Skulpt implementation client-side, but that requires the Full Python environment only available to paid users. So for this demo, I only use the client-side unittest module (which is needed anyway for tests of client-only functionality), though I also provide the server-side way commented out.

4 Likes

Hi Tim, I have been using pytest to develop server-side code. All my tests are on my laptop. I clone my app, and then use the anvil.yaml file to generate a database definition. With this, and https://github.com/benlawraus/pyDALAnvilWorks I then use a sqlite database to run tests within PyCharm. Why bother? I really like PyCharm !

3 Likes

Awesome, I really appreciate you sharing this. (Actually, I think it deserves its own “Show and Tell” post.)

A few bugs to fix before doing that. I updated it to include any_of and all_of. You mind giving the script on the repo’s GitHub a run and let me know if it works? You need to clone the example app before doing so.

1 Like

I don’t think I’m going to get to this for a while. (For starters, I’d have to figure out how to run a .zsh, though I probably should already know.) Maybe @owen.campbell or @stefano.menci or others would be interested in giving it a try?

oh sorry, just copy and past the terminal part of the README into your terminal. I wonder if I should put the entire address of my anvil app there so you do not have to copy the anvil app to your account. There is no security risk right? I mean the xxxxxx part:
git clone ssh://ben.yyyyy@anvil.works:2222/xxxxxxxxxxx.git pyDALAnvilWorksApp

OK, I see. I don’t think there is any risk, as long as you don’t mind sharing your email address, but I don’t know enough to feel comfortable giving advice on it. I think the way you have it is fine, since folks will want to know how to do it with their own apps, anyhow.

Started on anvil_designer. Now I can use PyCharm to run tests on client side code. There is even some auto-complete on form components in PyCharm.

To do this I used the form_template.yaml files that you download in your git from anvil.works.

I know the anvil folks put in a lot of work on their new editor, but I like PyCharm too much to let go…

1 Like

Love this. I still haven’t made time to test your stuff, but I’m determined to do so. I’ve always wanted PyCharm (or another full-featured editor) to integrate better with Anvil. Actually, on that note, I want to make sure you’ve seen this discussion: PyCharm Integration

My understanding is that the most expert Anvil users tend to all switch back and forth between the Anvil IDE and their local editor (if not work entirely offline).

1 Like

Dude, that github project is seriously hardcore.

Anvil should use it or do something like in a Pycharm / VSC extension so we don’t have to do any kind of manual linking to use high powered bazooka IDEs.

1 Like

I would give a kidney to have this. Seriously I will pay for this kind of extension to be developed, as long as it’s done by Anvil and not a one off thing.

2 Likes

@nathanguyette as far I know it is definetly possible to comission certain features at anvil.

3 Likes

See Visual Studio Code and PyCharm Type Provider Extension :slight_smile:

1 Like

Thanks for spending the time to write up this framework. I really appreciate it.

That being said, I’m wondering what the purpose of this is?

time.sleep(1)

in the “startup” is?

Also curious, is there a way to stop execution of the program if any of the tests fail? Throw an error and terminate on the first failing test?

That I don’t know off-hand, and I also can’t remember the purpose of that sleep line, unfortunately.

But I’ll just note that my most recent testing-demo app is here:

Also, I think the state of the art is local testing with amoni, but it’s a little more involved and I haven’t tried it out myself yet:

2 Likes