Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

repo sync #17399

Merged
merged 2 commits into from
Apr 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ The examples below demonstrate using the `fwal/setup-swift` action.

### Using multiple Swift versions

You can configure your job to use a multiple versions of Swift in a build matrix.
You can configure your job to use multiple versions of Swift in a matrix.

```yaml{:copy}
{% data reusables.actions.actions-not-certified-by-github-comment %}
Expand Down
22 changes: 11 additions & 11 deletions content/actions/learn-github-actions/contexts.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ miniTocMaxHeadingLevel: 3

Contexts are a way to access information about workflow runs, runner environments, jobs, and steps. Each context is an object that contains properties, which can be strings or other objects.

{% data reusables.actions.context-contents %} For example, the `matrix` context is only populated for jobs in a [build matrix](/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idstrategymatrix).
{% data reusables.actions.context-contents %} For example, the `matrix` context is only populated for jobs in a [matrix](/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idstrategymatrix).

You can access contexts using the expression syntax. For more information, see "[Expressions](/actions/learn-github-actions/expressions)."

Expand Down Expand Up @@ -552,19 +552,19 @@ The following example contents of the `secrets` context shows the automatic `GIT

## `strategy` context

For workflows with a build matrix, the `strategy` context contains information about the matrix execution strategy for the current job.
For workflows with a matrix, the `strategy` context contains information about the matrix execution strategy for the current job.

| Property name | Type | Description |
|---------------|------|-------------|
| `strategy` | `object` | This context changes for each job in a workflow run. You can access this context from any job or step in a workflow. This object contains all the properties listed below. |
| `strategy.fail-fast` | `string` | When `true`, all in-progress jobs are canceled if any job in a build matrix fails. For more information, see "[Workflow syntax for {% data variables.product.prodname_actions %}](/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idstrategyfail-fast)." |
| `strategy.job-index` | `string` | The index of the current job in the build matrix. **Note:** This number is a zero-based number. The first job's index in the build matrix is `0`. |
| `strategy.job-total` | `string` | The total number of jobs in the build matrix. **Note:** This number **is not** a zero-based number. For example, for a build matrix with four jobs, the value of `job-total` is `4`. |
| `strategy.fail-fast` | `string` | When `true`, all in-progress jobs are canceled if any job in a matrix fails. For more information, see "[Workflow syntax for {% data variables.product.prodname_actions %}](/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idstrategyfail-fast)." |
| `strategy.job-index` | `string` | The index of the current job in the matrix. **Note:** This number is a zero-based number. The first job's index in the matrix is `0`. |
| `strategy.job-total` | `string` | The total number of jobs in the matrix. **Note:** This number **is not** a zero-based number. For example, for a matrix with four jobs, the value of `job-total` is `4`. |
| `strategy.max-parallel` | `string` | The maximum number of jobs that can run simultaneously when using a `matrix` job strategy. For more information, see "[Workflow syntax for {% data variables.product.prodname_actions %}](/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idstrategymax-parallel)." |

### Example contents of the `strategy` context

The following example contents of the `strategy` context is from a build matrix with four jobs, and is taken from the final job. Note the difference between the zero-based `job-index` number, and `job-total` which is not zero-based.
The following example contents of the `strategy` context is from a matrix with four jobs, and is taken from the final job. Note the difference between the zero-based `job-index` number, and `job-total` which is not zero-based.

```yaml
{
Expand All @@ -577,7 +577,7 @@ The following example contents of the `strategy` context is from a build matrix

### Example usage of the `strategy` context

This example workflow uses the `strategy.job-index` property to set a unique name for a log file for each job in a build matrix.
This example workflow uses the `strategy.job-index` property to set a unique name for a log file for each job in a matrix.

```yaml{:copy}
name: Test matrix
Expand All @@ -602,18 +602,18 @@ jobs:

## `matrix` context

For workflows with a build matrix, the `matrix` context contains the matrix properties defined in the workflow file that apply to the current job. For example, if you configure a build matrix with the `os` and `node` keys, the `matrix` context object includes the `os` and `node` properties with the values that are being used for the current job.
For workflows with a matrix, the `matrix` context contains the matrix properties defined in the workflow file that apply to the current job. For example, if you configure a matrix with the `os` and `node` keys, the `matrix` context object includes the `os` and `node` properties with the values that are being used for the current job.

There are no standard properties in the `matrix` context, only those which are defined in the workflow file.

| Property name | Type | Description |
|---------------|------|-------------|
| `matrix` | `object` | This context is only available for jobs in a build matrix, and changes for each job in a workflow run. You can access this context from any job or step in a workflow. This object contains the properties listed below. |
| `matrix` | `object` | This context is only available for jobs in a matrix, and changes for each job in a workflow run. You can access this context from any job or step in a workflow. This object contains the properties listed below. |
| `matrix.<property_name>` | `string` | The value of a matrix property. |

### Example contents of the `matrix` context

The following example contents of the `matrix` context is from a job in a build matrix that has the `os` and `node` matrix properties defined in the workflow. The job is executing the matrix combination of an `ubuntu-latest` OS and Node.js version `16`.
The following example contents of the `matrix` context is from a job in a matrix that has the `os` and `node` matrix properties defined in the workflow. The job is executing the matrix combination of an `ubuntu-latest` OS and Node.js version `16`.

```yaml
{
Expand All @@ -624,7 +624,7 @@ The following example contents of the `matrix` context is from a job in a build

### Example usage of the `matrix` context

This example workflow creates a build matrix with `os` and `node` keys. It uses the `matrix.os` property to set the runner type for each job, and uses the `matrix.node` property to set the Node.js version for each job.
This example workflow creates a matrix with `os` and `node` keys. It uses the `matrix.os` property to set the runner type for each job, and uses the `matrix.node` property to set the Node.js version for each job.

```yaml{:copy}
name: Test matrix
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Both CircleCI and {% data variables.product.prodname_actions %} configure `jobs`

Both CircleCI and {% data variables.product.prodname_actions %} provide a mechanism to reuse and share tasks in a workflow. CircleCI uses a concept called orbs, written in YAML, to provide tasks that people can reuse in a workflow. {% data variables.product.prodname_actions %} has powerful and flexible reusable components called actions, which you build with either JavaScript files or Docker images. You can create actions by writing custom code that interacts with your repository in any way you'd like, including integrating with {% data variables.product.product_name %}'s APIs and any publicly available third-party API. For example, an action can publish npm modules, send SMS alerts when urgent issues are created, or deploy production-ready code. For more information, see "[Creating actions](/actions/creating-actions)."

CircleCI can reuse pieces of workflows with YAML anchors and aliases. {% data variables.product.prodname_actions %} supports the most common need for reusability using build matrixes. For more information about build matrixes, see "[Managing complex workflows](/actions/learn-github-actions/managing-complex-workflows/#using-a-build-matrix)."
CircleCI can reuse pieces of workflows with YAML anchors and aliases. {% data variables.product.prodname_actions %} supports the most common need for reusability using matrices. For more information about matrices, see "[Using a matrix for your jobs](/actions/using-jobs/using-a-matrix-for-your-jobs)."

## Using Docker images

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ Jenkins can run the `stages` and `steps` in parallel, while {% data variables.pr
| ------------- | ------------- |
| [`parallel`](https://jenkins.io/doc/book/pipeline/syntax/#parallel) | [`jobs.<job_id>.strategy.max-parallel`](/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#jobsjob_idstrategymax-parallel) |

### Build matrix
### Matrix

Both {% data variables.product.prodname_actions %} and Jenkins let you use a build matrix to define various system combinations.
Both {% data variables.product.prodname_actions %} and Jenkins let you use a matrix to define various system combinations.

| Jenkins | {% data variables.product.prodname_actions %} |
| ------------- | ------------- |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ Travis CI can use `stages` to run jobs in parallel. Similarly, {% data variables
Travis CI and {% data variables.product.prodname_actions %} both support status badges, which let you indicate whether a build is passing or failing.
For more information, see ["Adding a workflow status badge to your repository](/actions/managing-workflow-runs/adding-a-workflow-status-badge)."

### Using a build matrix
### Using a matrix

Travis CI and {% data variables.product.prodname_actions %} both support a build matrix, allowing you to perform testing using combinations of operating systems and software packages. For more information, see "[Using a build matrix](/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix)."
Travis CI and {% data variables.product.prodname_actions %} both support a matrix, allowing you to perform testing using combinations of operating systems and software packages. For more information, see "[Using a matrix for your jobs](/actions/using-jobs/using-a-matrix-for-your-jobs)."

Below is an example comparing the syntax for each system:

Expand Down
2 changes: 1 addition & 1 deletion content/actions/using-jobs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ children:
- /using-jobs-in-a-workflow
- /choosing-the-runner-for-a-job
- /using-conditions-to-control-job-execution
- /using-a-build-matrix-for-your-jobs
- /using-a-matrix-for-your-jobs
- /using-concurrency
- /using-environments-for-jobs
- /running-jobs-in-a-container
Expand Down
30 changes: 0 additions & 30 deletions content/actions/using-jobs/using-a-build-matrix-for-your-jobs.md

This file was deleted.

60 changes: 60 additions & 0 deletions content/actions/using-jobs/using-a-matrix-for-your-jobs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
title: Using a matrix for your jobs
shortTitle: Using a matrix
intro: Create a matrix to define variations for each job.
versions:
fpt: '*'
ghes: '*'
ghae: '*'
ghec: '*'
miniTocMaxHeadingLevel: 4
redirect_from:
- /actions/using-jobs/using-a-build-matrix-for-your-jobs
---

{% data reusables.actions.enterprise-beta %}
{% data reusables.actions.enterprise-github-hosted-runners %}

## About matrix strategies

{% data reusables.actions.jobs.about-matrix-strategy %}

## Using a matrix strategy

{% data reusables.actions.jobs.using-matrix-strategy %}

### Example: Using a single-dimension matrix

{% data reusables.actions.jobs.single-dimension-matrix %}

### Example: Using a multi-dimension matrix

{% data reusables.actions.jobs.multi-dimension-matrix %}

### Example: Using contexts to create matrices

{% data reusables.actions.jobs.matrix-from-context %}

## Expanding or adding matrix configurations

{% data reusables.actions.jobs.matrix-include %}

### Example: Expanding configurations

{% data reusables.actions.jobs.matrix-expand-with-include %}

### Example: Adding configurations

{% data reusables.actions.jobs.matrix-add-with-include %}

## Excluding matrix configurations

{% data reusables.actions.jobs.matrix-exclude %}

## Handling failures

{% data reusables.actions.jobs.section-using-a-build-matrix-for-your-jobs-failfast %}

## Defining the maximum number of concurrent jobs

{% data reusables.actions.jobs.section-using-a-build-matrix-for-your-jobs-max-parallel %}
8 changes: 4 additions & 4 deletions content/actions/using-workflows/about-workflows.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,24 +105,24 @@ jobs:

For more information, see "[Defining prerequisite jobs](/actions/using-jobs/using-jobs-in-a-workflow#defining-prerequisite-jobs)."

### Using a build matrix
### Using a matrix

You can use a build matrix if you want your workflow to run tests across multiple combinations of parameters, such as operating systems, platforms, and languages. The build matrix is created using the `strategy` keyword, which receives the build options as an array. For example, this build matrix will run the job multiple times, using different versions of Node.js:
{% data reusables.actions.jobs.about-matrix-strategy %} The matrix is created using the `strategy` keyword, which receives the build options as an array. For example, this matrix will run the job multiple times, using different versions of Node.js:

```yaml
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node: [6, 8, 10]
node: [12, 14, 16]
steps:
- uses: {% data reusables.actions.action-setup-node %}
with:
node-version: {% raw %}${{ matrix.node }}{% endraw %}
```

For more information, see "[Using a build matrix for your jobs](/actions/using-jobs/using-a-build-matrix-for-your-jobs)."
For more information, see "[Using a matrix for your jobs](/actions/using-jobs/using-a-matrix-for-your-jobs)."

{% ifversion fpt or ghec %}
### Caching dependencies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -745,11 +745,39 @@ If the timeout exceeds the job execution time limit for the runner, the job will

## `jobs.<job_id>.strategy`

{% data reusables.actions.jobs.section-using-a-build-matrix-for-your-jobs-strategy %}
Use `jobs.<job_id>.strategy` to use a matrix strategy for your jobs. {% data reusables.actions.jobs.about-matrix-strategy %} For more information, see "[Using a matrix for your jobs](/actions/using-jobs/using-a-matrix-for-your-jobs)."

### `jobs.<job_id>.strategy.matrix`

{% data reusables.actions.jobs.section-using-a-build-matrix-for-your-jobs-matrix %}
{% data reusables.actions.jobs.using-matrix-strategy %}

#### Example: Using a single-dimension matrix

{% data reusables.actions.jobs.single-dimension-matrix %}

#### Example: Using a multi-dimension matrix

{% data reusables.actions.jobs.multi-dimension-matrix %}

#### Example: Using contexts to create matrices

{% data reusables.actions.jobs.matrix-from-context %}

### `jobs.<job_id>.strategy.matrix.include`

{% data reusables.actions.jobs.matrix-include %}

#### Example: Expanding configurations

{% data reusables.actions.jobs.matrix-expand-with-include %}

#### Example: Adding configurations

{% data reusables.actions.jobs.matrix-add-with-include %}

### `jobs.<job_id>.strategy.matrix.exclude`

{% data reusables.actions.jobs.matrix-exclude %}

### `jobs.<job_id>.strategy.fail-fast`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ If this parameter is not used, the {% data variables.product.prodname_codeql_wor

{% data reusables.code-scanning.codeql-languages-bullets %}

The default {% data variables.product.prodname_codeql_workflow %} file contains a build matrix called `language` which lists the languages in your repository that are analyzed. {% data variables.product.prodname_codeql %} automatically populates this matrix when you add {% data variables.product.prodname_code_scanning %} to a repository. Using the `language` matrix optimizes {% data variables.product.prodname_codeql %} to run each analysis in parallel. We recommend that all workflows adopt this configuration due to the performance benefits of parallelizing builds. For more information about build matrices, see "[Managing complex workflows](/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix)."
The default {% data variables.product.prodname_codeql_workflow %} file contains a matrix called `language` which lists the languages in your repository that are analyzed. {% data variables.product.prodname_codeql %} automatically populates this matrix when you add {% data variables.product.prodname_code_scanning %} to a repository. Using the `language` matrix optimizes {% data variables.product.prodname_codeql %} to run each analysis in parallel. We recommend that all workflows adopt this configuration due to the performance benefits of parallelizing builds. For more information about matrices, see "[Using a matrix for your jobs](/actions/using-jobs/using-a-matrix-for-your-jobs)."

{% data reusables.code-scanning.specify-language-to-analyze %}

Expand Down
Loading