Automating WeChat Mini-Program builds with semi CI/CD

Here’s the secret sauce that helps Wiredcraft ensure high quality by implementing Continuous Integration and Continuous Delivery for WeChat Mini-Programs.

September has been a pretty intense period for Wiredcraft with 2 major WeChat Mini-Programs delivered in a week: Burberry and Nike.

Here’s a bit of the secret sauce that helps us ensure high quality by implementing Continuous Integration/Continuous Delivery for WeChat Mini-Programs (or as close to it as possible).

What’s it all about?

Here’s a quick overview on CI/CD and the WeChat specificities and how to combine them efficiently.

CI/CD

  • Run tests (unit, integration, code format, tech debt etc.) on commits
  • Generate a validated artifact
  • Push to dev/staging/production environments automatically

WeChat Mini-Program

  • Uses its own language derived from Javascript
  • Uses its own IDE, requiring multiple validations/security logins via QR code, with tight ACL control in the web admin interface,
  • Pushing to prod is a manual process, requiring code review by Tencent prior to the release

As we can see, full CI/CD is not achievable by the mere fact that releases need to be audited and require a click in the WeChat Admin Web interface.

But everything prior can be semi-automated, from push/pr/merge, all the way to publishing an experimental build suitable for your stakeholders to review.

How we can achieve CI/CD

Without diving into the specifics of testing (Jest, Coverage etc.) or tooling (Jenkins, Bamboo, Pipelines etc.), let’s shed some light on the glue that allows the (pre)-CD to occur.

The magic comes from our use of the WeChat IDE CLI and the ability to generate a login QR code as an image. This can be pushed through your favorite IM for remote scanning and eventual authentication of the IDE on your builder.

An example flow would be the following:

  • trigger the execution of the tests automatically
  • initiate a login on the IDE installed on the CI/CD host (e.g. on a Mac mini where your Jenkins agent is running)
  • push the generated QR code to a dedicated Slack Channel via a Slackbot
  • get your release team member to scan and auto-magically push the generated code on WeChat via the IDE CLI

Release team members could be your DevOps team or whoever else fits the role. Preferably someone not actively contributing to the dev-force, but whose contributions would be made as Experimental release user in the WeChat Admin web interface.

This means that their uploads would immediately be pushed as the experimental version of the Mini-Program, available to those with the QR code.

You can find a sample script achieving those steps here: https://github.com/Wiredcraft/cicd-utils/tree/master/wechat. Feel free to fork/submit PR etc.

Vincent Viallet
CEO
Posted on October 11, 2018 in Technology

Share this post

Scan to open in WeChat

Stay tuned

Follow our newsletter or our WeChat account; every other week you'll receive news about what we're up to, our events and our insights on digital products, omnichannel, cross-border ecommerce or whatever the team fancies.

  • Add us on WeChat

  • Subscribe to our newsletter