Skip to content

Commit 3af12e9

Browse files
authored
repo sync
2 parents d1233d7 + 3239d8a commit 3af12e9

File tree

946 files changed

+9178
-3473
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

946 files changed

+9178
-3473
lines changed
Lines changed: 236 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,236 @@
1+
---
2+
title: Building and testing PowerShell
3+
intro: You can create a continuous integration (CI) workflow to build and test your PowerShell project.
4+
product: '{% data reusables.gated-features.actions %}'
5+
versions:
6+
free-pro-team: '*'
7+
enterprise-server: '>=2.22'
8+
---
9+
10+
{% data reusables.actions.enterprise-beta %}
11+
{% data reusables.actions.enterprise-github-hosted-runners %}
12+
13+
### Einführung
14+
15+
This guide shows you how to use PowerShell for CI. It describes how to use Pester, install dependencies, test your module, and publish to the PowerShell Gallery.
16+
17+
{% data variables.product.prodname_dotcom %}-hosted runners have a tools cache with pre-installed software, which includes PowerShell and Pester. For a full list of up-to-date software and the pre-installed versions of PowerShell and Pester, see "[Specifications for {% data variables.product.prodname_dotcom %}-hosted runners](/actions/reference/specifications-for-github-hosted-runners/#supported-software)".
18+
19+
### Vorrausetzungen
20+
21+
Du solltest mit YAML und der Syntax für {% data variables.product.prodname_actions %} vertraut sein. For more information, see "[Learn {% data variables.product.prodname_actions %}](/actions/learn-github-actions)."
22+
23+
We recommend that you have a basic understanding of PowerShell and Pester. Weitere Informationen findest Du unter:
24+
- [Getting started with PowerShell](https://docs.microsoft.com/powershell/scripting/learn/ps101/01-getting-started)
25+
- [Pester](https://pester.dev)
26+
27+
{% data reusables.actions.enterprise-setup-prereq %}
28+
29+
### Adding a workflow for Pester
30+
31+
To automate your testing with PowerShell and Pester, you can add a workflow that runs every time a change is pushed to your repository. In the following example, `Test-Path` is used to check that a file called `resultsfile.log` is present.
32+
33+
This example workflow file must be added to your repository's `.github/workflows/` directory:
34+
35+
{% raw %}
36+
```yaml
37+
name: Test PowerShell on Ubuntu
38+
on: push
39+
40+
jobs:
41+
pester-test:
42+
name: Pester test
43+
runs-on: ubuntu-latest
44+
steps:
45+
- name: Check out repository code
46+
uses: actions/checkout@v2
47+
- name: Perform a Pester test from the command-line
48+
shell: pwsh
49+
run: Test-Path resultsfile.log | Should -Be $true
50+
- name: Perform a Pester test from the Tests.ps1 file
51+
shell: pwsh
52+
run: |
53+
Invoke-Pester Unit.Tests.ps1 -Passthru
54+
```
55+
{% endraw %}
56+
57+
* `shell: pwsh` - Configures the job to use PowerShell when running the `run` commands.
58+
* `run: Test-Path resultsfile.log` - Check whether a file called `resultsfile.log` is present in the repository's root directory.
59+
* `Should -Be $true` - Uses Pester to define an expected result. If the result is unexpected, then {% data variables.product.prodname_actions %} flags this as a failed test. Ein Beispiel:
60+
61+
![Failed Pester test](/assets/images/help/repository/actions-failed-pester-test.png)
62+
63+
* `Invoke-Pester Unit.Tests.ps1 -Passthru` - Uses Pester to execute tests defined in a file called `Unit.Tests.ps1`. For example, to perform the same test described above, the `Unit.Tests.ps1` will contain the following:
64+
```
65+
Describe "Check results file is present" {
66+
It "Check results file is present" {
67+
Test-Path resultsfile.log | Should -Be $true
68+
}
69+
}
70+
```
71+
72+
### PowerShell module locations
73+
74+
The table below describes the locations for various PowerShell modules in each {% data variables.product.prodname_dotcom %}-hosted runner.
75+
76+
| | Ubuntu | macOS | Windows |
77+
| ----------------------------- | ------------------------------------------------ | ------------------------------------------------- | ------------------------------------------------------------ |
78+
| **PowerShell system modules** | `/opt/microsoft/powershell/7/Modules/*` | `/usr/local/microsoft/powershell/7/Modules/*` | `C:\program files\powershell\7\Modules\*` |
79+
| **PowerShell add-on modules** | `/usr/local/share/powershell/Modules/*` | `/usr/local/share/powershell/Modules/*` | `C:\Modules\*` |
80+
| **User-installed modules** | `/home/runner/.local/share/powershell/Modules/*` | `/Users/runner/.local/share/powershell/Modules/*` | `C:\Users\runneradmin\Documents\PowerShell\Modules\*` |
81+
82+
### Abhängigkeiten installieren
83+
84+
{% data variables.product.prodname_dotcom %}-hosted runners have PowerShell 7 and Pester installed. You can use `Install-Module` to install additional dependencies from the PowerShell Gallery before building and testing your code.
85+
86+
{% note %}
87+
88+
**Note:** The pre-installed packages (such as Pester) used by {% data variables.product.prodname_dotcom %}-hosted runners are regularly updated, and can introduce significant changes. As a result, it is recommended that you always specify the required package versions by using `Install-Module` with `-MaximumVersion`.
89+
90+
{% endnote %}
91+
92+
Du kannst Abhängigkeiten auch im Cache zwischenspeichern, um Deinen Workflow zu beschleunigen. Weitere Informationen findest Du unter „[Abhängigkeiten im Cache zwischenspeichern, um Deinen Workflow zu beschleunigen](/actions/automating-your-workflow-with-github-actions/caching-dependencies-to-speed-up-workflows)“.
93+
94+
For example, the following job installs the `SqlServer` and `PSScriptAnalyzer` modules:
95+
96+
{% raw %}
97+
```yaml
98+
jobs:
99+
install-dependencies:
100+
name: Install dependencies
101+
runs-on: ubuntu-latest
102+
steps:
103+
- uses: actions/checkout@v2
104+
- name: Install from PSGallery
105+
shell: pwsh
106+
run: |
107+
Set-PSRepository PSGallery -InstallationPolicy Trusted
108+
Install-Module SqlServer, PSScriptAnalyzer
109+
```
110+
{% endraw %}
111+
112+
{% note %}
113+
114+
**Note:** By default, no repositories are trusted by PowerShell. When installing modules from the PowerShell Gallery, you must explicitly set the installation policy for `PSGallery` to `Trusted`.
115+
116+
{% endnote %}
117+
118+
#### Abhängigkeiten „cachen“ (zwischenspeichern)
119+
120+
You can cache PowerShell dependencies using a unique key, which allows you to restore the dependencies for future workflows with the [`cache`](https://github.com/marketplace/actions/cache) action. For more information, see "[Caching dependencies to speed up workflows](/actions/automating-your-workflow-with-github-actions/caching-dependencies-to-speed-up-workflows)."
121+
122+
PowerShell caches its dependencies in different locations, depending on the runner's operating system. For example, the `path` location used in the following Ubuntu example will be different for a Windows operating system.
123+
124+
{% raw %}
125+
```yaml
126+
steps:
127+
- uses: actions/checkout@v2
128+
- name: Setup PowerShell module cache
129+
id: cacher
130+
uses: actions/cache@v2
131+
with:
132+
path: "~/.local/share/powershell/Modules"
133+
key: ${{ runner.os }}-SqlServer-PSScriptAnalyzer
134+
- name: Install required PowerShell modules
135+
if: steps.cacher.outputs.cache-hit != 'true'
136+
shell: pwsh
137+
run: |
138+
Set-PSRepository PSGallery -InstallationPolicy Trusted
139+
Install-Module SqlServer, PSScriptAnalyzer -ErrorAction Stop
140+
```
141+
{% endraw %}
142+
143+
### Deinen Code testen
144+
145+
Du kannst die gleichen Befehle verwenden, die Du auch lokal verwendest, um Deinen Code zu erstellen und zu testen.
146+
147+
#### Using PSScriptAnalyzer to lint code
148+
149+
The following example installs `PSScriptAnalyzer` and uses it to lint all `ps1` files in the repository. For more information, see [PSScriptAnalyzer on GitHub](https://github.com/PowerShell/PSScriptAnalyzer).
150+
151+
{% raw %}
152+
```yaml
153+
lint-with-PSScriptAnalyzer:
154+
name: Install and run PSScriptAnalyzer
155+
runs-on: ubuntu-latest
156+
steps:
157+
- uses: actions/checkout@v2
158+
- name: Install PSScriptAnalyzer module
159+
shell: pwsh
160+
run: |
161+
Set-PSRepository PSGallery -InstallationPolicy Trusted
162+
Install-Module PSScriptAnalyzer -ErrorAction Stop
163+
- name: Lint with PSScriptAnalyzer
164+
shell: pwsh
165+
run: |
166+
Invoke-ScriptAnalyzer -Path *.ps1 -Recurse -Outvariable issues
167+
$errors = $issues.Where({$_.Severity -eq 'Error'})
168+
$warnings = $issues.Where({$_.Severity -eq 'Warning'})
169+
if ($errors) {
170+
Write-Error "There were $($errors.Count) errors and $($warnings.Count) warnings total." -ErrorAction Stop
171+
} else {
172+
Write-Output "There were $($errors.Count) errors and $($warnings.Count) warnings total."
173+
}
174+
```
175+
{% endraw %}
176+
177+
### Workflow-Daten als Artefakte paketieren
178+
179+
You can upload artifacts to view after a workflow completes. Zum Beispiel kann es notwendig sein, Logdateien, Core Dumps, Testergebnisse oder Screenshots zu speichern. Weitere Informationen findest Du unter "[Workflow-Daten mittels Artefakten persistieren](/github/automating-your-workflow-with-github-actions/persisting-workflow-data-using-artifacts)."
180+
181+
The following example demonstrates how you can use the `upload-artifact` action to archive the test results received from `Invoke-Pester`. For more information, see the [`upload-artifact` action](https://github.com/actions/upload-artifact).
182+
183+
{% raw %}
184+
```yaml
185+
name: Upload artifact from Ubuntu
186+
187+
on: [push]
188+
189+
jobs:
190+
upload-pester-results:
191+
name: Run Pester and upload results
192+
runs-on: ubuntu-latest
193+
steps:
194+
- uses: actions/checkout@v2
195+
- name: Test with Pester
196+
shell: pwsh
197+
run: Invoke-Pester Unit.Tests.ps1 -Passthru | Export-CliXml -Path Unit.Tests.xml
198+
- name: Upload test results
199+
uses: actions/upload-artifact@v2
200+
with:
201+
name: ubuntu-Unit-Tests
202+
path: Unit.Tests.xml
203+
if: ${{ always() }}
204+
```
205+
{% endraw %}
206+
207+
The `always()` function configures the job to continue processing even if there are test failures. For more information, see "[always](/actions/reference/context-and-expression-syntax-for-github-actions#always)."
208+
209+
### Publishing to PowerShell Gallery
210+
211+
You can configure your workflow to publish your PowerShell module to the PowerShell Gallery when your CI tests pass. You can use repository secrets to store any tokens or credentials needed to publish your package. Weitere Informationen findest Du unter "[Verschlüsselte Geheimnisse erstellen und verwenden](/github/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets)".
212+
213+
The following example creates a package and uses `Publish-Module` to publish it to the PowerShell Gallery:
214+
215+
{% raw %}
216+
```yaml
217+
name: Publish PowerShell Module
218+
219+
on:
220+
release:
221+
types: [created]
222+
223+
jobs:
224+
publish-to-gallery:
225+
runs-on: ubuntu-latest
226+
steps:
227+
- uses: actions/checkout@v2
228+
- name: Build and publish
229+
env:
230+
NUGET_KEY: ${{ secrets.NUGET_KEY }}
231+
shell: pwsh
232+
run: |
233+
./build.ps1 -Path /tmp/samplemodule
234+
Publish-Module -Path /tmp/samplemodule -NuGetApiKey $env:NUGET_KEY -Verbose
235+
```
236+
{% endraw %}

translations/de-DE/content/actions/guides/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ You can use {% data variables.product.prodname_actions %} to create custom conti
2929
{% link_in_list /about-continuous-integration %}
3030
{% link_in_list /setting-up-continuous-integration-using-workflow-templates %}
3131
{% link_in_list /building-and-testing-nodejs %}
32+
{% link_in_list /building-and-testing-powershell %}
3233
{% link_in_list /building-and-testing-python %}
3334
{% link_in_list /building-and-testing-java-with-maven %}
3435
{% link_in_list /building-and-testing-java-with-gradle %}

translations/de-DE/content/actions/guides/storing-workflow-data-as-artifacts.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,12 @@ Von den Artefakten eines vorherigen Auftrags abhängige Aufträge müssen auf de
171171

172172
Auftrag 1 führt die folgenden Schritte durch:
173173
- Führt eine mathematische Berechnung aus und speichert das Ergebnis in einer Textdatei namens `math-homework.txt`.
174-
- Verwendet die Aktion `upload-artifact`, um die Datei `math-homework.txt` mit dem Namen `homework` hochzuladen. Die Aktion platziert die Datei in einem Verzeichnis mit dem Namen `homework`.
174+
- Uses the `upload-artifact` action to upload the `math-homework.txt` file with the artifact name `homework`.
175175

176176
Auftrag 2 verwendet das Ergebnis des vorherigen Auftrags:
177177
- Lädt das im vorherigen Auftrag hochgeladene `homework`-Artefakt herunter. Die Aktion `download-artifact` lädt die Artefakte standardmäßig in das Verzeichnis der Arbeitsoberfläche, in dem der Schritt ausgeführt wird. Du kannst den Eingabeparameter `path` verwenden, um ein anderes Download-Verzeichnis anzugeben.
178-
- Liest den Wert in der Datei `homework/math-homework.txt`, führt eine mathematische Berechnung durch und speichert das Ergebnis in `math-homework.txt`.
179-
- Lädt die Datei `math-homework.txt` hoch. Dieser Upload überschreibt den vorherigen Upload, da beide Uploads den gleichen Namen haben.
178+
- Reads the value in the `math-homework.txt` file, performs a math calculation, and saves the result to `math-homework.txt` again, overwriting its contents.
179+
- Lädt die Datei `math-homework.txt` hoch. This upload overwrites the previously uploaded artifact because they share the same name.
180180

181181
Auftrag 3 zeigt das im vorherigen Auftrag hochgeladene Ergebnis an:
182182
- Lädt das `homework`-Artefakt herunter.

translations/de-DE/content/actions/hosting-your-own-runners/about-self-hosted-runners.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ Du musst sicherstellen, dass der Rechner über den entsprechenden Netzwerkzugrif
111111
github.com
112112
api.github.com
113113
*.actions.githubusercontent.com
114+
codeload.github.com
114115
```
115116

116117
If you use an IP address allow list for your {% data variables.product.prodname_dotcom %} organization or enterprise account, you must add your self-hosted runner's IP address to the allow list. For more information, see "[Managing allowed IP addresses for your organization](/github/setting-up-and-managing-organizations-and-teams/managing-allowed-ip-addresses-for-your-organization#using-github-actions-with-an-ip-allow-list)" or "[Enforcing security settings in your enterprise account](/github/setting-up-and-managing-your-enterprise/enforcing-security-settings-in-your-enterprise-account#using-github-actions-with-an-ip-allow-list)".

translations/de-DE/content/actions/index.md

Lines changed: 22 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,34 @@ shortTitle: GitHub Actions
44
intro: 'Mit {% data variables.product.prodname_actions %} kannst Du Deine Softwareentwicklungs-Workflows direkt in Ihrem Repository automatisieren, anpassen und ausführen. Du kannst Actions entdecken, erstellen und weitergeben, um beliebige Aufträge (einschließlich CI/CD) auszuführen. Du kannst auch Actions in einem vollständig angepassten Workflow kombinieren.'
55
introLinks:
66
quickstart: /actions/quickstart
7-
learn: /actions/learn-github-actions
7+
reference: /actions/reference
88
featuredLinks:
9+
guides:
10+
- /actions/guides/setting-up-continuous-integration-using-workflow-templates
11+
- /actions/guides/about-packaging-with-github-actions
912
gettingStarted:
1013
- /actions/managing-workflow-runs
1114
- /actions/hosting-your-own-runners
12-
guide:
13-
- /actions/guides/setting-up-continuous-integration-using-workflow-templates
14-
- /actions/guides/about-packaging-with-github-actions
1515
popular:
1616
- /actions/reference/workflow-syntax-for-github-actions
1717
- /actions/reference/events-that-trigger-workflows
18+
changelog:
19+
-
20+
title: Self-Hosted Runner Group Access Changes
21+
date: '2020-10-16'
22+
href: https://github.blog/changelog/2020-10-16-github-actions-self-hosted-runner-group-access-changes/
23+
-
24+
title: Ability to change retention days for artifacts and logs
25+
date: '2020-10-08'
26+
href: https://github.blog/changelog/2020-10-08-github-actions-ability-to-change-retention-days-for-artifacts-and-logs
27+
-
28+
title: Deprecating set-env and add-path commands
29+
date: '2020-10-01'
30+
href: https://github.blog/changelog/2020-10-01-github-actions-deprecating-set-env-and-add-path-commands
31+
-
32+
title: Fine-tune access to external actions
33+
date: '2020-10-01'
34+
href: https://github.blog/changelog/2020-10-01-github-actions-fine-tune-access-to-external-actions
1835
redirect_from:
1936
- /articles/automating-your-workflow-with-github-actions/
2037
- /articles/customizing-your-project-with-github-actions/
@@ -36,44 +53,8 @@ versions:
3653
<!-- {% link_with_intro /hosting-your-own-runners %} -->
3754
<!-- {% link_with_intro /reference %} -->
3855

39-
<!-- Article links -->
40-
<div class="d-lg-flex gutter my-6 py-6">
41-
<div class="col-12 col-lg-4 mb-4 mb-lg-0">
42-
<div class="featured-links-heading pb-4">
43-
<h3 class="f5 text-normal text-mono underline-dashed color-gray-5">{% data ui.toc.guides %}</h3>
44-
</div>
45-
<ul class="list-style-none">
46-
{% for link in featuredLinks.guide %}
47-
<li>{% include featured-link %}</li>
48-
{% endfor %}
49-
</ul>
50-
</div>
51-
52-
<div class="col-12 col-lg-4 mb-4 mb-lg-0">
53-
<div class="featured-links-heading pb-4">
54-
<h3 class="f5 text-normal text-mono underline-dashed color-gray-5">{% data ui.toc.popular_articles %}</h3>
55-
</div>
56-
<ul class="list-style-none">
57-
{% for link in featuredLinks.popular %}
58-
<li>{% include featured-link %}</li>
59-
{% endfor %}
60-
</ul>
61-
</div>
62-
63-
<div class="col-12 col-lg-4 mb-4 mb-lg-0">
64-
<div class="featured-links-heading pb-4">
65-
<h3 class="f5 text-normal text-mono underline-dashed color-gray-5">Manage workflows</h3>
66-
</div>
67-
<ul class="list-style-none">
68-
{% for link in featuredLinks.gettingStarted %}
69-
<li>{% include featured-link %}</li>
70-
{% endfor %}
71-
</ul>
72-
</div>
73-
</div>
74-
7556
<!-- Code examples -->
76-
<div class="mt-6 pt-6">
57+
<div class="my-6 pt-6">
7758
<h2 class="mb-2">More guides</h2>
7859

7960
<div class="d-flex flex-wrap gutter">

translations/de-DE/content/actions/learn-github-actions/finding-and-customizing-actions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ For more information, see "[Using release management for actions](/actions/creat
8787

8888
### Using inputs and outputs with an action
8989

90-
An action often accepts or requires inputs and generates outputs that you can use. For example, an action might require you to specify a path to a file, the name of a label, or other data it will uses as part of the action processing.
90+
An action often accepts or requires inputs and generates outputs that you can use. For example, an action might require you to specify a path to a file, the name of a label, or other data it will use as part of the action processing.
9191

9292
To see the inputs and outputs of an action, check the `action.yml` or `action.yaml` in the root directory of the repository.
9393

@@ -149,7 +149,7 @@ jobs:
149149
verwendet: docker://alpine:3.8
150150
```
151151

152-
For some examples of Docker actions, see the [Docker-image.yml workflow](https://github.com/actions/starter-workflows/blob/main/ci/docker-image.yml) and "[Creating a Docker container action](/articles/creating-a-docker-container-action)."
152+
Einige Beispiele für Docker-Aktionen findest Du im [Docker-image.yml-Workflow](https://github.com/actions/starter-workflows/blob/main/ci/docker-image.yml) oder unter „[Eine Docker-Container-Aktion erstellen](/articles/creating-a-docker-container-action)“.
153153

154154
### Nächste Schritte:
155155

translations/de-DE/content/actions/learn-github-actions/index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ versions:
3636
{% link_with_intro /managing-complex-workflows %}
3737
{% link_with_intro /sharing-workflows-with-your-organization %}
3838
{% link_with_intro /security-hardening-for-github-actions %}
39+
{% link_with_intro /migrating-from-azure-pipelines-to-github-actions %}
3940
{% link_with_intro /migrating-from-circleci-to-github-actions %}
4041
{% link_with_intro /migrating-from-gitlab-cicd-to-github-actions %}
41-
{% link_with_intro /migrating-from-azure-pipelines-to-github-actions %}
4242
{% link_with_intro /migrating-from-jenkins-to-github-actions %}
43+
{% link_with_intro /migrating-from-travis-ci-to-github-actions %}

0 commit comments

Comments
 (0)