dburkart / check-sieve

Syntax checker for mail sieves.
MIT License
34 stars 7 forks source link

Add Snapcraft #56

Closed johnlettman closed 10 months ago

johnlettman commented 10 months ago

This pull request implements a Snapcraft definition for the check-sieve application as an alternative distribution and packaging method. Snaps are one of the many handy and portable ways of targeting several Linux distributions simultaneously for consumption.

The definition overrides the pull strategy to extract the version information from the last tag automatically. When the version is not published, it will jump to that tag for the build (e.g., 8.0); otherwise, it will produce a build tagged with the commit identifier (e.g., 704d7c2). The override suits CI/CD and automated GitHub workflow publishing.

Lastly, the package is fairly lightweight:

This arises, most likely, from the compression and high optimization flags.

Example

$ snap info check-sieve

name:      check-sieve
summary:   Syntax checker for mail sieves
publisher: –
license:   unset (*)
description: |
  Makes checking mail sieve syntax easy and painless.
  Because breaking your sieve in production sucks.
commands:
  - check-sieve
refresh-date: today at 19:55 EDT
installed:    v0.8 (x1) 139kB devmode

(*) follow-up commit will fix license metadata

$ rcat test.sieve

require ["copy", "environment", "imapsieve"];

if anyof (environment :is "imap.cause" "APPEND",
        environment :is "imap.cause" "COPY")  {
if environment :is "imap.mailbox" "ActionItems" {
        redirect :copy "actionitems@example.com";
}
}

$ /snap/bin/check-sieve test.sieve

test.sieve: No errors found!
johnlettman commented 10 months ago

Ultimately, if/when this is merged, I will have a follow-up PR to implement a GitHub workflow to automatically publish master to Snap Store so it doesn't add any development steps.

The worst amount of labor is setting a repository secret AFAIK.

Saviq commented 10 months ago

Ultimately, if/when this is merged, I will have a follow-up PR to implement a GitHub workflow to automatically publish master to Snap Store so it doesn't add any development steps.

@johnlettman this can be handled with a webhook directly by the Snap Store, btw: https://snapcraft.io/build

johnlettman commented 10 months ago

@Saviq Oh, now that's pretty slick. TIL and thank you!

johnlettman commented 10 months ago

@dburkart I agree the Build from GitHub service mentioned by @Saviq is the most sensible approach as it will offload the build minutes from your runners. https://snapcraft.io/docs/build-from-github

The steps boil down to:

  1. Log into the My snaps page
  2. Use the GitHub login button.
  3. Choose this repository and click Start building

After that, the build service will take over, using the snapcraft.yaml file in the repo to continuously integrate new commits and merges.

dburkart commented 10 months ago

Done: https://snapcraft.io/check-sieve

johnlettman commented 10 months ago

Perf! Works:


$ snap install --edge check-sieve
check-sieve (edge) 0.8 from Dana Burkart (dburkart) installed

$ which check-sieve
/snap/bin/check-sieve

$ check-sieve ~/repos/mail-sieves/sieves/00-advertisements.sieve 
/home/jlettman/repos/mail-sieves/sieves/00-advertisements.sieve: No errors found!

$ snap info check-sieve  
name:      check-sieve
summary:   Syntax checker for mail sieves
publisher: Dana Burkart (dburkart)
store-url: https://snapcraft.io/check-sieve
contact:   XXXXX
license:   MIT
description: |
  Makes checking mail sieve syntax easy and painless. Because breaking your sieve in production
  sucks.
commands:
  - check-sieve
snap-id:      QYVTYrffsi2KQMRa5FTQn32Y4K34CW4o
tracking:     latest/edge
refresh-date: today at 15:28 EDT
channels:
  latest/stable:    –                        
  latest/candidate: –                        
  latest/beta:      –                        
  latest/edge:      0.8 2023-09-04 (1) 143kB -
installed:          0.8            (1) 143kB -