AleksaC / azure-pipelines-templates

Collection of Azure Pipelines templates for jobs and tasks I commonly use in my projects

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

azure-pipelines-templates πŸš€

license Build Status pre-commit

Collection of Azure Pipelines templates for jobs and tasks I commonly use in my projects.

Getting started βš™οΈ

You can expand on the following sample azure-pipelines.yml configuration:

resources:
  repositories:
    - repository: aleksac
      type: github
      endpoint: AleksaC
      name: AleksaC/azure-pipelines-templates
      ref: refs/tags/v0.0.2

jobs:
  - template: jobs/pre-commit.yml@aleksac

Note: You need to set the endpoint to the name of the github service connection you've set up.

Tasks πŸ“

Pushes changes to GitHub. Uses InstallSSHKey task to provide authentication. Take a look at its documentation to see how to set it up. Note that you need to set KNOWN_HOST_ENTRY and SSH_PUBLIC_KEY variables. Make sure to add quotes when adding the variables so they are parsed correctly. For security make sure that secrets aren't passed to builds for pull requests from forks (Edit -> Triggers -> Pull request validation). Since the secrets should not be passed to validation of PRs from forks the push task is not ran for those builds either.

Parameters:

  • username - git username
  • commitMessage
  • displayName - name to be displayed for the pushing task
  • condition - condition on which it depends whether the push task will be executed (default: suceed())
  • skipCI - determines whether to skip CI on pushed commit (only skips azure pipelines) (default: true)
  • sshKeySecureFile - name of the secure file containing the private key corresponding to github deploy key that was set up (default: id_rsa)

For sample usage take a look at pre-commit.yml job.

Install python interpreters using deadsnakes ppa. Can only be used with Ubuntu images.

Parameters:

  • version - python version to install (default: "3.8")
  • condition - condition on which it depends whether the push task will be executed (default: suceed())

For sample usage take a look at python-tests.yml job.

Set up go toolchain and environment.

Parameters:

  • goVersion - version of go to use (default: "1.14")
  • goPath - path to set as goPath input to GoTool task (default: $(Agent.HomeDirectory)/go)

Jobs πŸ’Ό

Runs pre-commit on all files and optionally pushes autofixes back to the branch that triggered the build. For more information look at the official documentation.

Parameters:

  • python - python version to be used by pre-commit (default: "3.8")
  • pushAutofixes - whether to push autofixes (default: true)

Runs python tests using tox. Tests can be ran on multiple versions of python interpreter (python 3.5-3.8 and pypy3 on all platforms as well as python 3.9 and 3.10 on linux) as well as multiple operating systems (you need to define separate jobs for each operating system).

Parameters:

  • toxenvs - names of the tox environments to run
  • os - linux, windows or macos (default: linux)
  • coverage - whether to publish coverage artifact (default: true)
  • additionalVariables - additional job variables
  • preTest - list of tasks to run before running tests
  • namePostfix - string to be appended to the name of the job

Uses sphinx-apidoc to generate documentation for new modules and push them back to the branch that triggered the build. Uses tox by default (see sample config).

Parameters:

  • python - python version (default: "3.8")
  • preGenerate - list of steps to run before generating documentation
  • generateCommand - task for generating the docs (default: script: tox -e docs)
  • postGenerate - list of tasks to run after generating the docs

Runs a build for a node project (e.g. creating production webpack bundles) and publishes the resulting artifact.

Parameters:

  • node - node version to use (default: "12.x")
  • artifactName
  • artifactPath - path to the artifact to be published
  • preInstall - list of tasks to run before installing npm packages
  • installCommand - command to run for installing npm packages - useful if you want to use yarn instead of npm (default: npm install)
  • buildCommand - command to run for building the artifact (default: npm run build)
  • additionalVariables - additional job variables
  • namePostfix - string to be appended to the name of the job

Syncs an artifact to a directory within an S3 bucket, including deletion of the files that are no longer present in the artifact.

Parameters:

  • artifactName
  • bucketPath - path to the directory where to upload the artifact starting with the bucket name
  • dependsOn - job or a list of jobs this job depends on
  • condition - condition on which it depends whether the artifact will be synced (default: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master')))

Example:

- template: jobs/sync-artifact-to-S3.yml@aleksac
    parameters:
      artifactName: artifact
      bucketPath: foo/bar
      dependsOn: build
      condition: succeeded()

In the example above the contents of the directory bar in the bucket foo would be synced with the contents of the artifact artifact if a job named build succeeded before it.

Runs golang tests with coverage. Tests can be ran for multiple versions of go compiler as well as multiple operating systems (you need to define separate jobs for each operating system). For coverage to work you need to run the job from the root of the go module.

Parameters:

  • goVersions - versions of go compiler to use (default: ["1.14"])
  • packages - argument to go test (default: ./...)
  • os - linux, windows or macos (default: linux)
  • coverage - whether to publish coverage artifact (default: true)
  • additionalVariables - additional job variables
  • preTest - list of tasks to run before running tests
  • namePostfix - string to be appended to the name of the job

Contact πŸ™‹β€β™‚οΈ

About

Collection of Azure Pipelines templates for jobs and tasks I commonly use in my projects

License:MIT License


Languages

Language:Python 53.7%Language:Makefile 21.2%Language:Batchfile 20.7%Language:Go 4.4%