Skip to content

Commit

Permalink
Cleanup questions (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
FidelusAleksander authored Sep 6, 2023
1 parent 3966777 commit e8202ec
Show file tree
Hide file tree
Showing 20 changed files with 32 additions and 42 deletions.
2 changes: 1 addition & 1 deletion content/questions/question-006.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ subject: []
- [x] Workflows can be triggered manually, by an event or run on a schedule
- [x] Workflows have to be defined in the `.github/workflows` directory
- [ ] Workflows can only be run on a schedule
- [ ] Workflow can run one job at a time
- [ ] Workflow can run only one job at a time
- [ ] Workflows are written in any of `.yaml`, `.json` or `.toml` formats
- [ ] Workflows can be shared in Github Marketplace
> Actions (not workflows) can be shared in Github Marketplace
2 changes: 1 addition & 1 deletion content/questions/question-014.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ draft: false
subject: []
---

# This is code will launch 6 different jobs in parallel using the matrix strategy. Can You use the matrix strategy to parallelize entire workflows?
# This code will launch 6 different jobs in parallel using the matrix strategy. Can You use the matrix strategy to parallelize entire workflows?

```yaml
jobs:
Expand Down
2 changes: 1 addition & 1 deletion content/questions/question-025.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ draft: false
subject: []
---

# You want to create a reusable workflow `CI` that runs some quality checks, linting or tests on code changes. What event trigger should the `CI` workflow define to allow reusing it in other workflows?
# You want to create a reusable workflow `CI` that runs some quality checks, linting and tests on code changes. What event trigger should the `CI` workflow define to allow reusing it in other workflows?
> https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows
1. [x] workflow_call
1. [ ] workflow_trigger
Expand Down
4 changes: 1 addition & 3 deletions content/questions/question-026.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ draft: false
subject: []
---

# A reusable workflow named `build` creates zip file artifacts. How do You pass the zip file location to the caller workflow that is using the `build` workflow?
# A reusable workflow named `build` creates zip file artifacts. How do You pass the zip file location to the caller workflow that is calling the `build` workflow?
> https://docs.github.com/en/actions/using-workflows/reusing-workflows#using-outputs-from-a-reusable-workflow
- [x] You define an output on workflow level in the `build` workflow
> https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-of-onworkflow_calloutputs
- [x] You define an output on job level in the `build` workflow
> https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idoutputs
- [x] In the `build` workflow You write the output into `$GITHUB_OUTPUT` in one of the steps
- [ ] All outputs are automatically passed to the caller workflows
2 changes: 1 addition & 1 deletion content/questions/question-028.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ draft: false
subject: []
---

# How can You ensure that a workflow called "Deploy Prod" is always running at most one at a time?
# How can You ensure that a workflow called `Deploy Prod` is always running at most one at a time?
> https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#concurrency
1. [x] Use `concurrency` on workflow level
Expand Down
2 changes: 1 addition & 1 deletion content/questions/question-029.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ draft: false
subject: []
---

# Your Pull Request analysis workflow uses multiple code analysis tools and takes about 20minutes to fully complete. It is triggered on `pull_request` event that target master branch, that means if a developer pushes multiple commits within few minutes multiple workflows are running in parallel. How can You stop all previous workflow runs and only run the one with latest changes?
# Your Pull Request analysis workflow uses multiple code analysis tools and takes about 20minutes to fully complete. It is triggered on `pull_request` event with `branches` filter set to `master`. Therefore if a developer pushes multiple commits within few minutes multiple workflows are running in parallel. How can You stop all previous workflow runs and only run the one with latest changes?
> https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-using-concurrency-to-cancel-any-in-progress-job-or-run
1. [x] Use concurrency with cancel-in-progress
Expand Down
1 change: 0 additions & 1 deletion content/questions/question-031.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ subject: []
```
> https://docs.github.com/en/actions/learn-github-actions/contexts#github-context
- [x] `if: github.repository == 'my-org/my-repo'`
> You may omit the ${{ }} expression syntax in `if` conditionals
- [x] `if: ${{ github.repository == 'my-org/my-repo' }}`
- [ ] `if: ${{ github.organization == 'my-org' && github.repository == 'my-repo' }}`
> https://docs.github.com/en/actions/learn-github-actions/contexts#github-context
Expand Down
4 changes: 2 additions & 2 deletions content/questions/question-034.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ subject: []
---


# When using actions published in public repositories maintained by someone else - You can often use that action in multiple versions. Rank the different approaches from most to least stable.
# For any action published in GitHub Marketplace, You can often use it in multiple versions, rank the different approaches from most to least stable and secure.
> https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-using-versioned-actions
1. Using the commit SHA
```yaml
Expand All @@ -16,7 +16,7 @@ subject: []
```yaml
uses: actions/checkout@v3
```
3. Using the master branch
3. Using the main branch
```yaml
uses: actions/checkout@main
```
8 changes: 4 additions & 4 deletions content/questions/question-035.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,25 @@ subject: []

# To prevent a job from failure when one of the steps fails You can include:
> https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepscontinue-on-error
1. [x] Add `continue-on-error` flag in the failing step
1. [x] `continue-on-error` flag in the failing step
```yaml
steps:
- uses: my-org/failing-action@v1
continue-on-error: true
```
1. [ ] Add `ignore-error` flag in the failing step
1. [ ] `ignore-error` flag in the failing step
```yaml
steps:
- uses: my-org/failing-action@v1
ignore-error: true
```
1. [ ] Add `failure()` conditional in the failing step
1. [ ] `failure()` conditional in the failing step
```yaml
steps:
- uses: my-org/failing-action@v1
if: failure()
```
1. [ ] Add `always()` conditional in the failing step
1. [ ] `always()` conditional in the failing step
```yaml
steps:
- uses: my-org/failing-action@v1
Expand Down
6 changes: 3 additions & 3 deletions content/questions/question-036.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ draft: false
subject: []
---

# You defined a matrix job `example_matrix`. How can limit the matrix to run a maximum of 2 jobs at the same time?
# You defined a matrix job `example_matrix`. How can limit the matrix to run a maximum of 2 jobs at a time?

```yaml
jobs:
Expand All @@ -16,7 +16,7 @@ subject: []
os: [ubuntu-latest, windows-latest]
```
> https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstrategymax-parallel
1. [x] Set jobs.example_matrix.strategy.max-parallel to 2
1. [ ] Set jobs.example_matrix.strategy.concurrency to 2
1. [x] Set `jobs.example_matrix.strategy.max-parallel` to 2
1. [ ] Set `jobs.example_matrix.strategy.concurrency` to 2
1. [ ] Use Github's REST API to check if the job count is lesser than 2
1. [ ] It's not possible, a matrix will always run all of the jobs in parallel if there are runners available
4 changes: 0 additions & 4 deletions content/questions/question-041.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ subject: []

# When should You use `caching`?

```yaml
uses: actions/cache@v3
```
> https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#comparing-artifacts-and-dependency-caching
1. [x] When you want to reuse files that don't change often between jobs or workflow runs, such as build dependencies from a package management system.
Expand Down
13 changes: 5 additions & 8 deletions content/questions/question-042.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,11 @@ subject: []

# When should You use `artifacts`?

```yaml
uses: actions/upload-artifact@v3
```
> https://docs.github.com/en/actions/using-workflows/storing-workflow-data-as-artifacts#about-workflow-artifacts
- [x] When you want to save files produced by a job to view after a workflow run has ended, such as test results or build logs.
- [x] When you want to save binaries produced by a build job to use in a subsequent deploy job to deploy a new version of an application
- [ ] When you want to reuse files that don't change often between jobs or workflow runs, such as build dependencies from a package management system.
- [x] Use artifacts to save files produced by a job to view after a workflow run has ended, such as test results or build logs.
- [x] Use artifacts to save binaries produced by a build job to use in a subsequent deploy job to deploy a new version of an application
- [ ] Use artifacts to reuse files that don't change often between jobs or workflow runs, such as build dependencies from a package management system.
> Caching should be used for that https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#comparing-artifacts-and-dependency-caching
- [ ] When you want to reuse files that do change often between jobs or workflow runs, such as build dependencies from a package management system.
- [ ] Use artifacts to create new versions of Your application together with release notes, mentions and/or contributors
> That's a use case for releases, not artifacts
2 changes: 1 addition & 1 deletion content/questions/question-043.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ draft: false
subject: []
---

# If a workflow runs on a `feature-a` branch, can it restore caches created in the default `main` branch?
# If a workflow runs on a `feature-a` branch, can it restore `caches` created in the default `main` branch?

> https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#restrictions-for-accessing-a-cache
1. [x] Yes, all branches can restore caches created on the default branch
Expand Down
8 changes: 4 additions & 4 deletions content/questions/question-044.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ draft: false
subject: []
---

# In a workflow run to access an `artifact` that was created in another workflow run using `actions/upload-artifact` You can:
# To access an `artifact` that was created in another, previously triggered workflow run You can:

> https://docs.github.com/en/actions/using-workflows/storing-workflow-data-as-artifacts#about-workflow-artifacts
1. [x] You cannot access `artifacts` that were created in a different workflow run
1. [ ] You have to use the `actions/download-artifact` action.
1. [ ] You have to use the `actions/upload-artifact` action.
1. [ ] You have to use the `actions/download-artifact` action and make sure the artifact is not expired
1. [ ] Use the `actions/download-artifact` action.
1. [ ] Use the `actions/upload-artifact` action.
1. [ ] Use the `actions/download-artifact` action and make sure the artifact is not expired
2 changes: 1 addition & 1 deletion content/questions/question-045.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ draft: false
subject: []
---

# What should You use to store coverage reports or screenshots generated during a workflow that runs Your automated testing?
# What should You use to store coverage reports or screenshots generated during a workflow that runs automated testing for a repository?

> https://docs.github.com/en/actions/using-workflows/storing-workflow-data-as-artifacts#comparing-artifacts-and-dependency-caching
1. [x] Artifacts
Expand Down
2 changes: 1 addition & 1 deletion content/questions/question-048.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ draft: false
subject: []
---

# A job called `job2` is using artifacts created in `job1`. To make sure `job1` finished before `job2` starts looking for the artifacts how should You create that dependency?
# A job called `job2` is using artifacts created in `job1`. Therefore it's important to make sure `job1` finishes before `job2` starts looking for the artifacts. How should You create that dependency?

> https://github.com/sede-x/osdu-dpsolutions-gha-commons/pull/40/commits/f46cc3161059ec787afa78c3875b9f5288d3f73c
Expand Down
2 changes: 1 addition & 1 deletion content/questions/question-049.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ subject: []
# Which is true about `Starter Workflows` ?

> https://docs.github.com/en/actions/using-workflows/creating-starter-workflows-for-your-organization
- [x] They allow users to leverage ready-to-use (or with minimal changes) workflow templates when using Github UI
- [x] They allow users to leverage ready-to-use (or requiring minimal changes) workflow templates
- [x] Github provides and maintains starter workflows for different categories, languages and tooling
- [x] Your organization can create custom starter workflows for users in Your organization
- [ ] Starter workflows cannot call reusable workflows
Expand Down
4 changes: 2 additions & 2 deletions content/questions/question-053.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ draft: false
subject: []
---

# When creating a custom Github Action You have to store the source code in `.github/` directory
# When creating a custom Github Action You have to store the source code in `.github/workflows` directory
> https://docs.github.com/en/actions/creating-actions/about-custom-actions#choosing-a-location-for-your-action
1. [x] False
1. [ ] True
> That is true for `workflows`
> That is true for `workflows`, not for `actions`
2 changes: 1 addition & 1 deletion content/questions/question-054.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ subject: []

# When creating custom Github Actions - in what file all the action `metadata` has to be defined?

Metadata such as name or description of the action, the outputs or required inputs etc
Metadata examples: name, description, outputs or required inputs
> https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions
1. [x] In the `action.yml` or `action.yaml` file in the action repository
1. [ ] In the repository `README` file
Expand Down
2 changes: 1 addition & 1 deletion content/questions/question-056.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ draft: false
subject: []
---

# How can You require a workflow to be manually approved by a maintainer if the workflow run is targeting the `production` environment?
# How can You require manual approvals by a maintainer if the workflow run is targeting the `production` environment?
> https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment
1. [x] Using deployment protection rules
1. [ ] Setting the required required reviewers in the `production` workflow
Expand Down

0 comments on commit e8202ec

Please sign in to comment.