--- type: slide slideOptions: transition: slide width: 1400 height: 900 margin: 0.1 --- # Workflow automation --- ## Why Automation? - Run tests frequently, give feedback early etc. - Cannot forget automatized tasks - Less burden to developer (and their workstation) - Running predefined workflows/pipelines is simple - Ensure reproducible test environments --- ## Typical Tasks - Check code formatting and quality - Compile and test code for different platforms - Periodically run big tests, nightly builds, etc. - Build documentation and deploy it - Generate coverage reports and visualization - Process often integrated in development workflow (Git hooks or Git forges) --- # GitHub Actions --- ## What is "GitHub Actions"? > Automate, customize, and execute your software development workflows right in your repository with GitHub Actions. From: [https://docs.github.com/en/actions](https://docs.github.com/en/actions) --- ## Components (1/2) - [Workflow](https://docs.github.com/en/actions/using-workflows): Runs one or more jobs - [Event](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows): Triggers a workflow - [Jobs](https://docs.github.com/en/actions/using-jobs): Set of steps (running on same runner) - Steps executed consecutively and share data - Jobs by default executed in parallel - [Action](https://docs.github.com/en/actions/creating-actions): Application performing common, complex task (step) often used in workflows - [Runner](https://docs.github.com/en/actions/learn-github-actions/understanding-github-actions#runners): Server that runs jobs - [Artifacts](https://docs.github.com/en/actions/learn-github-actions/essential-features-of-github-actions#sharing-data-between-jobs): Files to be shared between jobs or to be kept after workflow finishes --- ## Components (2/2) From [GitHub Actions tutorial](https://docs.github.com/en/actions) --- ## Setting up a Workflow - Workflow file files stored `${REPO_ROOT}/.github/workflows` - Configured via YAML file ```yaml name: learn-github-actions on: [push] jobs: check-bats-version: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - uses: actions/setup-node@v2 with: node-version: '14' - run: npm install -g bats - run: bats -v ``` --- ## Actions ```yaml - uses: actions/checkout@v2 - uses: actions/setup-node@v2 with: node-version: '14' ``` - Integrated via `uses` directive - Additional configuration via `with` (options depend on Action) - Find action in [marketplace](https://github.com/marketplace?type=actions) - Write [own action](https://docs.github.com/en/actions/creating-actions) --- ## User-specified Commands ```yaml - name: "Single line command" run: echo "Single line command" - name: "Multi line command" run: | echo "First line" echo "Second line. Directory ${PWD}" workdir: tmp/ shell: bash ``` --- ## Events - Single or multiple events ```yaml on: [push, fork] ``` - Activities ```yaml on: issue: types: - opened - labeled ``` - Filters ```yaml on: push: branches: - main - 'releases/**' ``` --- ## Artifacts - Data sharing between jobs and data upload - Uploading artifact ```yaml - name: "Upload artifact" uses: actions/upload-artifact@v2 with: name: my-artifact path: my_file.txt retention-days: 5 ``` --- ## Further Reading - [GitHub Actions documentation](https://docs.github.com/en/actions) - [GitHub Actions quickstart](https://docs.github.com/en/actions/quickstart) --- ## Acknowledgement B. Uekermann, A. Jaust, I. Desai, "Lecture Material of Simulation Software Engineering" https://github.com/Simulation-Software-Engineering/Lecture-Material