From 5cef9e2fe7b8bedf6d97fb3647a04a84a94d4f1e Mon Sep 17 00:00:00 2001 From: Lucas Costi Date: Wed, 18 May 2022 10:35:40 +1000 Subject: [PATCH] Remove Actions experimental articles (#27524) --- components/article/ArticlePage.tsx | 6 - components/context/PlaygroundContext.tsx | 4 - .../nodejs.tsx | 536 ----------------- .../python.tsx | 564 ------------------ .../building-and-testing-nodejs-or-python.md | 18 - .../building-and-testing-nodejs.md | 2 - .../building-and-testing-python.md | 2 - .../automating-builds-and-tests/index.md | 3 +- ...rating-from-travis-ci-to-github-actions.md | 3 +- .../building-and-testing-nodejs-or-python.tsx | 5 - 10 files changed, 4 insertions(+), 1139 deletions(-) delete mode 100644 components/playground/content/actions/guides/building-and-testing-nodejs-or-python/nodejs.tsx delete mode 100644 components/playground/content/actions/guides/building-and-testing-nodejs-or-python/python.tsx delete mode 100644 content/actions/automating-builds-and-tests/building-and-testing-nodejs-or-python.md delete mode 100644 pages/[versionId]/actions/automating-builds-and-tests/building-and-testing-nodejs-or-python.tsx diff --git a/components/article/ArticlePage.tsx b/components/article/ArticlePage.tsx index 7ce139d09685..64870ad3ad61 100644 --- a/components/article/ArticlePage.tsx +++ b/components/article/ArticlePage.tsx @@ -22,12 +22,6 @@ const ClientSideHighlightJS = dynamic(() => import('./ClientSideHighlightJS'), { // Mapping of a "normal" article to it's interactive counterpart const interactiveAlternatives: Record = { - '/actions/automating-builds-and-tests/building-and-testing-nodejs': { - href: '/actions/automating-builds-and-tests/building-and-testing-nodejs-or-python?langId=nodejs', - }, - '/actions/automating-builds-and-tests/building-and-testing-python': { - href: '/actions/automating-builds-and-tests/building-and-testing-nodejs-or-python?langId=python', - }, '/codespaces/setting-up-your-project-for-codespaces/setting-up-your-nodejs-project-for-codespaces': { href: '/codespaces/setting-up-your-project-for-codespaces/setting-up-your-project-for-codespaces?langId=nodejs', diff --git a/components/context/PlaygroundContext.tsx b/components/context/PlaygroundContext.tsx index 67a7a2c78714..f2753d855574 100644 --- a/components/context/PlaygroundContext.tsx +++ b/components/context/PlaygroundContext.tsx @@ -2,16 +2,12 @@ import React, { createContext, useContext, useState } from 'react' import { CodeLanguage, PlaygroundArticleT } from 'components/playground/types' import { useRouter } from 'next/router' -import actionsJsArticle from 'components/playground/content/actions/guides/building-and-testing-nodejs-or-python/nodejs' -import actionsPyArticle from 'components/playground/content/actions/guides/building-and-testing-nodejs-or-python/python' import codespacesJsArticle from 'components/playground/content/codespaces/setting-up-your-project-for-codespaces/setting-up-your-project-for-codespaces/nodejs' import codespacesPyArticle from 'components/playground/content/codespaces/setting-up-your-project-for-codespaces/setting-up-your-project-for-codespaces/python' import codespacesNetArticle from 'components/playground/content/codespaces/setting-up-your-project-for-codespaces/setting-up-your-project-for-codespaces/dotnet' import codespacesJavaArticle from 'components/playground/content/codespaces/setting-up-your-project-for-codespaces/setting-up-your-project-for-codespaces/java' const articles = [ - actionsJsArticle, - actionsPyArticle, codespacesJsArticle, codespacesPyArticle, codespacesJavaArticle, diff --git a/components/playground/content/actions/guides/building-and-testing-nodejs-or-python/nodejs.tsx b/components/playground/content/actions/guides/building-and-testing-nodejs-or-python/nodejs.tsx deleted file mode 100644 index 13f4b5de6f20..000000000000 --- a/components/playground/content/actions/guides/building-and-testing-nodejs-or-python/nodejs.tsx +++ /dev/null @@ -1,536 +0,0 @@ -import dedent from 'ts-dedent' -import { PlaygroundArticleT } from 'components/playground/types' - -const article: PlaygroundArticleT = { - title: 'Building and testing Node.js', - shortTitle: 'Build & test Node.js', - topics: ['CI', 'Node', 'JavaScript'], - type: 'tutorial', - slug: '/actions/automating-builds-and-tests/building-and-testing-nodejs-or-python', - originalArticle: '/actions/automating-builds-and-tests/building-and-testing-nodejs', - codeLanguageId: 'nodejs', - intro: dedent` - This guide shows you how to create a continuous integration (CI) workflow that builds and tests Node.js code. If your CI tests pass, you may want to deploy your code or publish a package. - `, - prerequisites: dedent` - We recommend that you have a basic understanding of Node.js, YAML, workflow configuration options, and how to create a workflow file. For more information, see: - - - [Learn GitHub Actions](/actions/learn-github-actions) - - [Getting started with Node.js](https://nodejs.org/en/docs/guides/getting-started-guide/) - `, - contentBlocks: [ - { - codeBlock: { - id: '0', - }, - type: 'default', - title: 'Using the Node.js starter workflow', - content: dedent` - GitHub provides a Node.js starter workflow that will work for most Node.js projects. This guide includes npm and Yarn examples that you can use to customize the starter workflow. For more information, see the [Node.js starter workflow](https://github.com/actions/starter-workflows/blob/main/ci/node.js.yml). - - To get started quickly, add the starter workflow to the \`.github/workflows\` directory of your repository. The example workflow assumes that the default branch for your repository is \`main\`. - `, - }, - { - codeBlock: { - id: '0', - highlight: 12, - }, - type: 'default', - title: 'Running on a different operating system', - content: dedent` - The starter workflow configures jobs to run on Linux, using the GitHub-hosted \`ubuntu-latest\` runners. You can change the \`runs-on\` key to run your jobs on a different operating system. For example, you can use the GitHub-hosted Windows runners. - - \`\`\`yaml - runs-on: windows-latest - \`\`\` - - Or, you can run on the GitHub-hosted macOS runners. - - \`\`\`yaml - runs-on: macos-latest - \`\`\` - - You can also run jobs in Docker containers, or you can provide a self-hosted runner that runs on your own infrastructure. For more information, see "[Workflow syntax for GitHub Actions](/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#jobsjob_idruns-on)." - `, - }, - { - codeBlock: { - id: '0', - highlight: [14, 23], - }, - type: 'default', - title: 'Specifying the Node.js version', - content: dedent` - The easiest way to specify a Node.js version is by using the \`setup-node\` action provided by GitHub. For more information see, [\`setup-node\`](https://github.com/actions/setup-node/). - - The \`setup-node\` action takes a Node.js version as an input and configures that version on the runner. The \`setup-node\` action finds a specific version of Node.js from the tools cache on each runner and adds the necessary binaries to \`PATH\`, which persists for the rest of the job. Using the \`setup-node\` action is the recommended way of using Node.js with GitHub Actions because it ensures consistent behavior across different runners and different versions of Node.js. If you are using a self-hosted runner, you must install Node.js and add it to \`PATH\`. - - The starter workflow includes a matrix strategy that builds and tests your code with four Node.js versions: 10.x, 12.x, 14.x, and 15.x. The 'x' is a wildcard character that matches the latest minor and patch release available for a version. Each version of Node.js specified in the \`node-version\` array creates a job that runs the same steps. - - Each job can access the value defined in the matrix \`node-version\` array using the \`matrix\` context. The \`setup-node\` action uses the context as the \`node-version\` input. The \`setup-node\` action configures each job with a different Node.js version before building and testing code. For more information about matrix strategies and contexts, see "[Workflow syntax for GitHub Actions](/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#jobsjob_idstrategymatrix)" and "[Context and expression syntax for GitHub Actions](/actions/reference/context-and-expression-syntax-for-github-actions)." - `, - }, - { - codeBlock: { - id: '1', - highlight: 16, - }, - type: 'sub-section', - content: dedent` - Alternatively, you can build and test with exact Node.js versions. - `, - }, - { - codeBlock: { - id: '2', - highlight: 19, - }, - type: 'sub-section', - content: dedent` - Or, you can build and test using a single version of Node.js too. - - If you don't specify a Node.js version, GitHub uses the environment's default Node.js version. - For more information, see "[Specifications for GitHub-hosted runners](/actions/reference/specifications-for-github-hosted-runners/#supported-software)". - `, - }, - { - codeBlock: { - id: '3', - highlight: 21, - }, - type: 'default', - title: 'Installing dependencies', - content: dedent` - GitHub-hosted runners have npm and Yarn dependency managers installed. You can use npm and Yarn to install dependencies in your workflow before building and testing your code. The Windows and Linux GitHub-hosted runners also have Grunt, Gulp, and Bower installed. - - When using GitHub-hosted runners, you can also cache dependencies to speed up your workflow. For more information, see "[Caching dependencies to speed up workflows](/actions/guides/caching-dependencies-to-speed-up-workflows)." - `, - }, - { - codeBlock: { - id: '4', - highlight: 21, - }, - type: 'sub-section', - title: 'Example using npm', - content: dedent` - This example installs the dependencies defined in the *package.json* file. For more information, see [\`npm install\`](https://docs.npmjs.com/cli/install). - `, - }, - { - codeBlock: { - id: '2', - highlight: 21, - }, - type: 'sub-section-2', - content: dedent` - Using \`npm ci\` installs the versions in the *package-lock.json* or *npm-shrinkwrap.json* file and prevents updates to the lock file. Using \`npm ci\` is generally faster than running \`npm install\`. For more information, see [\`npm ci\`](https://docs.npmjs.com/cli/ci.html) and "[Introducing \`npm ci\` for faster, more reliable builds](https://blog.npmjs.org/post/171556855892/introducing-npm-ci-for-faster-more-reliable)." - `, - }, - { - codeBlock: { - id: '5', - highlight: [21, 23], - }, - type: 'sub-section', - title: 'Example using Yarn', - content: dedent` - This example installs the dependencies defined in the *package.json* file. For more information, see [\`yarn install\`](https://yarnpkg.com/en/docs/cli/install). - `, - }, - { - codeBlock: { - id: '6', - highlight: 21, - }, - type: 'sub-section-2', - content: dedent` - Alternatively, you can pass \`--frozen-lockfile\` to install the versions in the *yarn.lock* file and prevent updates to the *yarn.lock* file. - `, - }, - { - codeBlock: { - id: '7', - }, - type: 'sub-section', - title: 'Example using a private registry and creating the .npmrc file', - content: dedent` - You can use the \`setup-node\` action to create a local *.npmrc* file on the runner that configures the default registry and scope. The \`setup-node\` action also accepts an authentication token as input, used to access private registries or publish node packages. For more information, see [\`setup-node\`](https://github.com/actions/setup-node/). - - To authenticate to your private registry, you'll need to store your npm authentication token as a secret. For example, create a repository secret called \`NPM_TOKEN\`. For more information, see "[Creating and using encrypted secrets](/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets)." - - In this example, the secret \`NPM_TOKEN\` stores the npm authentication token. The \`setup-node\` action configures the *.npmrc* file to read the npm authentication token from the \`NODE_AUTH_TOKEN\` environment variable. When using the \`setup-node\` action to create an *.npmrc* file, you must set the \`NODE_AUTH_TOKEN\` environment variable with the secret that contains your npm authentication token. - - Before installing dependencies, use the \`setup-node\` action to create the *.npmrc* file. The action has two input parameters. The \`node-version\` parameter sets the Node.js version, and the \`registry-url\` parameter sets the default registry. If your package registry uses scopes, you must use the \`scope\` parameter. For more information, see [\`npm-scope\`](https://docs.npmjs.com/misc/scope). - - This example creates an *.npmrc* file with the following contents: - - \`\`\`ini - //registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN} - @octocat:registry=https://registry.npmjs.org/ - always-auth=true - \`\`\` - `, - }, - { - codeBlock: { - id: '8', - }, - type: 'sub-section', - title: 'Example caching dependencies', - content: dedent` - - When using GitHub-hosted runners, you can cache and restore the dependencies using the [\`setup-node\` action](https://github.com/actions/setup-node). To cache dependencies with the \`setup-node\` action, you must have a \`package-lock.json\`, \`yarn.lock\`, or \`pnpm-lock.yaml\` file in the root of the repository. - - If you have a custom requirement or need finer controls for caching, you can use the [\`cache\` action](https://github.com/marketplace/actions/cache). For more information, see [Caching dependencies to speed up workflows](/actions/guides/caching-dependencies-to-speed-up-workflows) and the [\`cache\` action](https://github.com/marketplace/actions/cache). - - `, - }, - { - codeBlock: { - id: '9', - highlight: [21, 22], - }, - type: 'default', - title: 'Building and testing your code', - content: dedent` - You can use the same commands that you use locally to build and test your code. For example, if you run \`npm run build\` to run build steps defined in your *package.json* file and \`npm test\` to run your test suite, you would add those commands in your workflow file. - `, - }, - { - codeBlock: { - id: '9', - }, - type: 'default', - title: 'Packaging workflow data as artifacts', - content: dedent` - You can save artifacts from your build and test steps to view after a job completes. For example, you may need to save log files, core dumps, test results, or screenshots. For more information, see "[Persisting workflow data using artifacts](/actions/automating-your-workflow-with-github-actions/persisting-workflow-data-using-artifacts)." - `, - }, - { - codeBlock: { - id: '9', - }, - type: 'default', - title: 'Publishing to package registries', - content: dedent` - You can configure your workflow to publish your Node.js package to a package registry after your CI tests pass. For more information about publishing to npm and GitHub Packages, see "[Publishing Node.js packages](/actions/automating-your-workflow-with-github-actions/publishing-nodejs-packages)." - `, - }, - ], - codeBlocks: { - '0': { - fileName: '.github/workflows/example.yml', - language: 'yaml', - code: dedent` - name: Node.js CI - - on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - - jobs: - build: - - runs-on: ubuntu-latest - - strategy: - matrix: - node-version: [10.x, 12.x, 14.x, 15.x] - - steps: - - uses: actions/checkout@v3 - - name: Use Node.js \${{ matrix.node-version }} - uses: actions/setup-node@v3 - with: - node-version: \${{ matrix.node-version }} - - name: Install dependencies - run: npm ci - - run: npm run build --if-present - - run: npm test - `, - }, - '1': { - fileName: '.github/workflows/example.yml', - language: 'yaml', - code: dedent` - name: Node.js CI - - on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - - jobs: - build: - - runs-on: ubuntu-latest - - strategy: - matrix: - node-version: [8.16.2, 10.17.0] - - steps: - - uses: actions/checkout@v3 - - name: Use Node.js \${{ matrix.node-version }} - uses: actions/setup-node@v3 - with: - node-version: \${{ matrix.node-version }} - - name: Install dependencies - run: npm ci - - run: npm run build --if-present - - run: npm test - `, - }, - '2': { - fileName: '.github/workflows/example.yml', - language: 'yaml', - code: dedent` - name: Node.js CI - - on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - - jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - name: Use Node.js - uses: actions/setup-node@v3 - with: - node-version: '12.x' - - name: Install dependencies - run: npm ci - - run: npm run build --if-present - - run: npm test - `, - }, - '3': { - fileName: '.github/workflows/example.yml', - language: 'yaml', - code: dedent` - name: Node.js CI - - on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - - jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - name: Use Node.js - uses: actions/setup-node@v3 - with: - node-version: '12.x' - - name: Install dependencies - run: npm install - - run: npm run build --if-present - - run: npm test - `, - }, - '4': { - fileName: '.github/workflows/example.yml', - language: 'yaml', - code: dedent` - name: Node.js CI - - on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - - jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - name: Use Node.js - uses: actions/setup-node@v3 - with: - node-version: '12.x' - - name: Install dependencies - run: npm install - - run: npm run build --if-present - - run: npm test - `, - }, - '5': { - fileName: '.github/workflows/example.yml', - language: 'yaml', - code: dedent` - name: Node.js CI - - on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - - jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - name: Use Node.js - uses: actions/setup-node@v3 - with: - node-version: '12.x' - - name: Install dependencies - run: yarn - - run: yarn run build - - run: yarn run test - `, - }, - '6': { - fileName: '.github/workflows/example.yml', - language: 'yaml', - code: dedent` - name: Node.js CI - - on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - - jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - name: Use Node.js - uses: actions/setup-node@v3 - with: - node-version: '12.x' - - name: Install dependencies - run: yarn --frozen-lockfile - - run: yarn run build - - run: yarn run test - `, - }, - '7': [ - { - fileName: '.github/workflows/example.yml', - language: 'yaml', - code: dedent` - name: Node.js CI - - on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - - jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - name: Use Node.js - uses: actions/setup-node@v3 - with: - always-auth: true - node-version: '12.x' - registry-url: https://registry.npmjs.org - scope: '@octocat' - - name: Install dependencies - run: npm ci - env: - NODE_AUTH_TOKEN: \${{secrets.NPM_TOKEN}} - `, - }, - { - fileName: '.npmrc', - language: 'ini', - code: dedent` - //registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN} - @octocat:registry=https://registry.npmjs.org/ - always-auth=true - `, - }, - ], - '8': { - fileName: '.github/workflows/example.yml', - language: 'yaml', - code: dedent` - name: Node.js CI - - on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - - jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - name: Use Node.js - uses: actions/setup-node@v3 - with: - node-version: '12.x' - cache: 'npm' - - name: Install dependencies - run: npm ci - `, - }, - '9': { - fileName: '.github/workflows/example.yml', - language: 'yaml', - code: dedent` - name: Node.js CI - - on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - - jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - name: Use Node.js - uses: actions/setup-node@v3 - with: - node-version: '12.x' - - run: npm install - - run: npm run build --if-present - - run: npm test - `, - }, - }, -} - -export default article diff --git a/components/playground/content/actions/guides/building-and-testing-nodejs-or-python/python.tsx b/components/playground/content/actions/guides/building-and-testing-nodejs-or-python/python.tsx deleted file mode 100644 index b9f1a0497648..000000000000 --- a/components/playground/content/actions/guides/building-and-testing-nodejs-or-python/python.tsx +++ /dev/null @@ -1,564 +0,0 @@ -import dedent from 'ts-dedent' -import { PlaygroundArticleT } from 'components/playground/types' - -const article: PlaygroundArticleT = { - title: 'Building and testing Python', - shortTitle: 'Build & test Python', - topics: ['CI', 'Python'], - type: 'tutorial', - slug: '/actions/automating-builds-and-tests/building-and-testing-nodejs-or-python', - originalArticle: '/actions/automating-builds-and-tests/building-and-testing-python', - codeLanguageId: 'py', - intro: dedent` - This guide shows you how to build, test, and publish a Python package. - - GitHub-hosted runners have a tools cache with pre-installed software, which includes Python and PyPy. You don't have to install anything! For a full list of up-to-date software and the pre-installed versions of Python and PyPy, see "[Specifications for GitHub-hosted runners](/actions/reference/specifications-for-github-hosted-runners/#supported-software)". - `, - prerequisites: dedent` - You should be familiar with YAML and the syntax for GitHub Actions. For more information, see "[Learn GitHub-Actions](/actions/learn-github-actions)." - - We recommend that you have a basic understanding of Python, PyPy, and pip. For more information, see: - - [Getting started with Python](https://www.python.org/about/gettingstarted/) - - [PyPy](https://pypy.org/) - - [Pip package manager](https://pypi.org/project/pip/) - `, - contentBlocks: [ - { - type: 'default', - codeBlock: { - id: '0', - }, - title: 'Using the Python starter workflow', - content: dedent` - GitHub provides a Python starter workflow that should work for most Python projects. This guide includes examples that you can use to customize the starter workflow. For more information, see the [Python starter workflow](https://github.com/actions/starter-workflows/blob/main/ci/python-package.yml). - - To get started quickly, add the starter workflow to the \`.github/workflows\` directory of your repository. - `, - }, - { - type: 'default', - codeBlock: { - id: '0', - }, - title: 'Specifying a Python version', - content: dedent` - To use a pre-installed version of Python or PyPy on a GitHub-hosted runner, use the \`setup-python\` action. This action finds a specific version of Python or PyPy from the tools cache on each runner and adds the necessary binaries to \`PATH\`, which persists for the rest of the job. If a specific version of Python is not pre-installed in the tools cache, the \`setup-python\` action will download and set up the appropriate version from the [\`python-versions\`](https://github.com/actions/python-versions) repository. - - Using the \`setup-python\` action is the recommended way of using Python with GitHub Actions because it ensures consistent behavior across different runners and different versions of Python. If you are using a self-hosted runner, you must install Python and add it to \`PATH\`. For more information, see the [\`setup-python\` action](https://github.com/marketplace/actions/setup-python). - - The table below describes the locations for the tools cache in each GitHub-hosted runner. - - || Ubuntu | Mac | Windows | - |------|-------|------|----------| - |**Tool Cache Directory** |\`/opt/hostedtoolcache/*\`|\`/Users/runner/hostedtoolcache/*\`|\`C:\hostedtoolcache\windows\*\`| - |**Python Tool Cache**|\`/opt/hostedtoolcache/Python/*\`|\`/Users/runner/hostedtoolcache/Python/*\`|\`C:\hostedtoolcache\windows\Python\*\`| - |**PyPy Tool Cache**|\`/opt/hostedtoolcache/PyPy/*\`|\`/Users/runner/hostedtoolcache/PyPy/*\`|\`C:\hostedtoolcache\windows\PyPy\*\`| - - If you are using a self-hosted runner, you can configure the runner to use the \`setup-python\` action to manage your dependencies. For more information, see [using setup-python with a self-hosted runner](https://github.com/actions/setup-python#using-setup-python-with-a-self-hosted-runner) in the \`setup-python\` README. - - GitHub supports semantic versioning syntax. For more information, see "[Using semantic versioning](https://docs.npmjs.com/about-semantic-versioning#using-semantic-versioning-to-specify-update-types-your-package-can-accept)" and the "[Semantic versioning specification](https://semver.org/)." - `, - }, - { - type: 'sub-section', - codeBlock: { - id: '1', - }, - title: 'Using multiple Python versions', - content: dedent` - This example uses a matrix to run the job on multiple Python versions: 2.7, 3.6, 3.7, 3.8, and 3.9. For more information about matrix strategies and contexts, see "[Workflow syntax for GitHub Actions](/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#jobsjob_idstrategymatrix)" and "[Context and expression syntax for GitHub Actions](/actions/reference/context-and-expression-syntax-for-github-actions)." - `, - }, - { - type: 'sub-section', - codeBlock: { - id: '2', - }, - title: 'Using a specific Python version', - content: dedent` - You can configure a specific version of python. For example, 3.8. Alternatively, you can use semantic version syntax to get the latest minor release. This example uses the latest minor release of Python 3. - `, - }, - { - type: 'sub-section', - codeBlock: { - id: '3', - }, - title: 'Excluding a version', - content: dedent` - If you specify a version of Python that is not available, \`setup-python\` fails with an error such as: \`##[error]Version 3.4 with arch x64 not found\`. The error message includes the available versions. - - You can also use the \`exclude\` keyword in your workflow if there is a configuration of Python that you do not wish to run. For more information, see "[Workflow syntax for GitHub Actions](/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#jobsjob_idstrategy)." - `, - }, - { - type: 'sub-section', - codeBlock: { - id: '3', - }, - title: 'Using the default Python version', - content: dedent` - We recommend using \`setup-python\` to configure the version of Python used in your workflows because it helps make your dependencies explicit. If you don't use \`setup-python\`, the default version of Python set in \`PATH\` is used in any shell when you call \`python\`. The default version of Python varies between GitHub-hosted runners, which may cause unexpected changes or use an older version than expected. - - | GitHub-hosted runner | Description | - |----|----| - | Ubuntu | Ubuntu runners have multiple versions of system Python installed under \`/usr/bin/python\` and \`/usr/bin/python3\`. The Python versions that come packaged with Ubuntu are in addition to the versions that GitHub installs in the tools cache. | - | Windows | Excluding the versions of Python that are in the tools cache, Windows does not ship with an equivalent version of system Python. To maintain consistent behavior with other runners and to allow Python to be used out-of-the-box without the \`setup-python\` action, GitHub adds a few versions from the tools cache to \`PATH\`.| - | macOS | The macOS runners have more than one version of system Python installed, in addition to the versions that are part of the tools cache. The system Python versions are located in the \`/usr/local/Cellar/python/*\` directory. | - `, - }, - { - type: 'default', - codeBlock: { - id: '4', - }, - title: 'Installing dependencies', - content: dedent` - GitHub-hosted runners have the pip package manager installed. You can use pip to install dependencies from the PyPI package registry before building and testing your code. This example installs or upgrades the \`pip\` package installer and the \`setuptools\` and \`wheel\` packages. - - When using GitHub-hosted runners, you can also cache dependencies to speed up your workflow. For more information, see "[Caching dependencies to speed up workflows](/actions/guides/caching-dependencies-to-speed-up-workflows)." - `, - }, - { - type: 'sub-section', - codeBlock: { - id: '5', - }, - title: 'Requirements file', - content: dedent` - After you update \`pip\`, a typical next step is to install dependencies from *requirements.txt*. - `, - }, - { - type: 'sub-section', - codeBlock: { - id: '6', - }, - title: 'Caching Dependencies', - content: dedent` - - When using GitHub-hosted runners, you can cache and restore the dependencies using the [\`setup-python\` action](https://github.com/actions/setup-python). By default, the \`setup-python\` action searches for the dependency file (\`requirements.txt\` for pip or \`Pipfile.lock\` for pipenv) in the whole repository. - - If you have a custom requirement or need finer controls for caching, you can use the [\`cache\` action](https://github.com/marketplace/actions/cache). Pip caches dependencies in different locations, depending on the operating system of the runner. The path you'll need to cache may differ from the Ubuntu example shown here, depending on the operating system you use. For more information, see [Caching dependencies to speed up workflows](/actions/guides/caching-dependencies-to-speed-up-workflows) and the [\`cache\` action](https://github.com/marketplace/actions/cache). - - `, - }, - { - type: 'default', - codeBlock: { - id: '7', - }, - title: 'Testing your code', - content: dedent` - You can use the same commands that you use locally to build and test your code. - `, - }, - { - type: 'sub-section', - codeBlock: { - id: '7', - }, - title: 'Testing with pytest and pytest-cov', - content: dedent` - This example installs or upgrades \`pytest\` and \`pytest-cov\`. Tests are then run and output in JUnit format while code coverage results are output in Cobertura. For more information, see [JUnit](https://junit.org/junit5/) and [Cobertura](https://cobertura.github.io/cobertura/). - `, - }, - { - type: 'sub-section', - codeBlock: { - id: '8', - }, - title: 'Using Flake8 to lint code', - content: dedent` - This example installs or upgrades \`flake8\` and uses it to lint all files. For more information, see [Flake8](http://flake8.pycqa.org/en/latest/). - `, - }, - { - type: 'sub-section', - codeBlock: { - id: '9', - }, - title: 'Running tests with tox', - content: dedent` - With GitHub Actions, you can run tests with tox and spread the work across multiple jobs. You'll need to invoke tox using the \`-e py\` option to choose the version of Python in your \`PATH\`, rather than specifying a specific version. For more information, see [tox](https://tox.readthedocs.io/en/latest/). - `, - }, - { - type: 'default', - codeBlock: { - id: '10', - }, - title: 'Packaging workflow data as artifacts', - content: dedent` - You can upload artifacts to view after a workflow completes. For example, you may need to save log files, core dumps, test results, or screenshots. For more information, see "[Persisting workflow data using artifacts](/github/automating-your-workflow-with-github-actions/persisting-workflow-data-using-artifacts)." - - This example demonstrates how you can use the \`upload-artifact\` action to archive test results from running \`pytest\`. For more information, see the [\`upload-artifact\` action](https://github.com/actions/upload-artifact). - `, - }, - { - type: 'default', - codeBlock: { - id: '11', - }, - title: 'Publishing to package registries', - content: dedent` - You can configure your workflow to publish your Python package to a package registry once your CI tests pass. This example demonstrates how you can use GitHub Actions to upload your package to PyPI each time you [publish a release](/github/administering-a-repository/managing-releases-in-a-repository). - - For this example, you will need to create two [PyPI API tokens](https://pypi.org/help/#apitoken). You can use secrets to store the access tokens or credentials needed to publish your package. For more information, see "[Creating and using encrypted secrets](/github/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets)." - - For more information about the starter workflow, see [\`python-publish\`](https://github.com/actions/starter-workflows/blob/main/ci/python-publish.yml). - `, - }, - ], - codeBlocks: { - '0': { - language: 'yaml', - fileName: '.github/workflows/example.yml', - code: dedent` - name: Python package - - on: [push] - - jobs: - build: - - runs-on: ubuntu-latest - strategy: - matrix: - python-version: ["3.6", "3.7", "3.8", "3.9"] - - steps: - - uses: actions/checkout@v3 - - name: Set up Python \${{ matrix.python-version }} - uses: actions/setup-python@v3 - with: - python-version: \${{ matrix.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install flake8 pytest - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - - name: Lint with flake8 - run: | - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Test with pytest - run: | - pytest - `, - }, - '1': { - language: 'yaml', - fileName: '.github/workflows/example.yml', - code: dedent` - name: Python package - - on: [push] - - jobs: - build: - - runs-on: ubuntu-latest - strategy: - # You can use PyPy versions in python-version. - # For example, pypy2 and pypy3 - matrix: - python-version: ["2.7", "3.6", "3.7", "3.8", "3.9"] - - steps: - - uses: actions/checkout@v3 - - name: Set up Python \${{ matrix.python-version }} - uses: actions/setup-python@v3 - with: - python-version: \${{ matrix.python-version }} - # You can test your matrix by printing the current Python version - - name: Display Python version - run: python -c "import sys; print(sys.version)" - `, - }, - '2': { - language: 'yaml', - fileName: '.github/workflows/example.yml', - code: dedent` - name: Python package - - on: [push] - - jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - name: Set up Python 3.x - uses: actions/setup-python@v3 - with: - # Semantic version range syntax or exact version of a Python version - python-version: '3.x' - # Optional - x64 or x86 architecture, defaults to x64 - architecture: 'x64' - # You can test your matrix by printing the current Python version - - name: Display Python version - run: python -c "import sys; print(sys.version)" - `, - }, - '3': { - language: 'yaml', - fileName: '.github/workflows/example.yml', - code: dedent` - name: Python package - - on: [push] - - jobs: - build: - - runs-on: \${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest, macos-latest, windows-latest] - python-version: ["3.6", "3.7", "3.8", "3.9", pypy2, pypy3] - exclude: - - os: macos-latest - python-version: "3.6" - - os: windows-latest - python-version: "3.6" - `, - }, - '4': { - language: 'yaml', - fileName: '.github/workflows/example.yml', - code: dedent` - name: Python package - - on: [push] - - jobs: - build: - - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v3 - with: - python-version: '3.x' - - name: Install dependencies - run: python -m pip install --upgrade pip setuptools wheel - `, - }, - '5': { - language: 'yaml', - fileName: '.github/workflows/example.yml', - code: dedent` - name: Python package - - on: [push] - - jobs: - build: - - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v3 - with: - python-version: '3.x' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r requirements.txt - `, - }, - '6': { - language: 'yaml', - fileName: '.github/workflows/example.yml', - code: dedent` - name: Python package - - on: [push] - - jobs: - build: - - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Setup Python - uses: actions/setup-python@v3 - with: - python-version: '3.x' - cache: 'pip' - - name: Install dependencies - run: pip install -r requirements.txt - `, - }, - '7': { - language: 'yaml', - fileName: '.github/workflows/example.yml', - code: dedent` - name: Python package - - on: [push] - - jobs: - build: - - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v3 - with: - python-version: '3.x' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r requirements.txt - - name: Test with pytest - run: | - pip install pytest - pip install pytest-cov - pytest tests.py --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html - `, - }, - '8': { - language: 'yaml', - fileName: '.github/workflows/example.yml', - code: dedent` - name: Python package - - on: [push] - - jobs: - build: - - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v3 - with: - python-version: '3.x' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r requirements.txt - - name: Lint with flake8 - run: | - pip install flake8 - flake8 . - `, - }, - '9': { - language: 'yaml', - fileName: '.github/workflows/example.yml', - code: dedent` - name: Python package - - on: [push] - - jobs: - build: - - runs-on: ubuntu-latest - strategy: - matrix: - python: ["3.7", "3.8", "3.9"] - - steps: - - uses: actions/checkout@v3 - - name: Setup Python - uses: actions/setup-python@v3 - with: - python-version: \${{ matrix.python }} - - name: Install Tox and any other packages - run: pip install tox - - name: Run Tox - # Run tox using the version of Python in \`PATH\` - run: tox -e py - `, - }, - '10': { - language: 'yaml', - fileName: '.github/workflows/example.yml', - code: dedent` - name: Python package - - on: [push] - - jobs: - build: - - runs-on: ubuntu-latest - strategy: - matrix: - python-version: ["3.6", "3.7", "3.8", "3.9"] - - steps: - - uses: actions/checkout@v3 - - name: Setup Python # Set Python version - uses: actions/setup-python@v3 - with: - python-version: \${{ matrix.python-version }} - # Install pip and pytest - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install pytest - - name: Test with pytest - run: pytest tests.py --doctest-modules --junitxml=junit/test-results-\${{ matrix.python-version }}.xml - - name: Upload pytest test results - uses: actions/upload-artifact@v3 - with: - name: pytest-results-\${{ matrix.python-version }} - path: junit/test-results-\${{ matrix.python-version }}.xml - # Use always() to always run this step to publish test results when there are test failures - if: \${{ always() }} - `, - }, - '11': { - language: 'yaml', - fileName: '.github/workflows/example.yml', - code: dedent` - # This workflow uses actions that are not certified by GitHub. - # They are provided by a third-party and are governed by - # separate terms of service, privacy policy, and support - # documentation. - - name: Upload Python Package - - on: - release: - types: [published] - - jobs: - deploy: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v3 - with: - python-version: '3.x' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install build - - name: Build package - run: python -m build - - name: Publish package - uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 - with: - user: __token__ - password: \${{ secrets.PYPI_API_TOKEN }} - `, - }, - }, -} - -export default article diff --git a/content/actions/automating-builds-and-tests/building-and-testing-nodejs-or-python.md b/content/actions/automating-builds-and-tests/building-and-testing-nodejs-or-python.md deleted file mode 100644 index e22a4239996f..000000000000 --- a/content/actions/automating-builds-and-tests/building-and-testing-nodejs-or-python.md +++ /dev/null @@ -1,18 +0,0 @@ ---- -title: Building and testing Node.js or Python -shortTitle: Build & test Node.js or Python -intro: You can create a continuous integration (CI) workflow to build and test your project. Use the language selector to show examples for your language of choice. -redirect_from: - - /actions/guides/building-and-testing-nodejs-or-python -versions: - fpt: '*' - ghes: '*' - ghae: '*' - ghec: '*' -type: tutorial -topics: - - CI ---- - - - diff --git a/content/actions/automating-builds-and-tests/building-and-testing-nodejs.md b/content/actions/automating-builds-and-tests/building-and-testing-nodejs.md index 027cbd2b0c86..48ecc1c776bf 100644 --- a/content/actions/automating-builds-and-tests/building-and-testing-nodejs.md +++ b/content/actions/automating-builds-and-tests/building-and-testing-nodejs.md @@ -11,13 +11,11 @@ versions: ghae: '*' ghec: '*' type: tutorial -hidden: true topics: - CI - Node - JavaScript shortTitle: Build & test Node.js -hasExperimentalAlternative: true --- {% data reusables.actions.enterprise-beta %} diff --git a/content/actions/automating-builds-and-tests/building-and-testing-python.md b/content/actions/automating-builds-and-tests/building-and-testing-python.md index 0ea960287813..4baa62ae7075 100644 --- a/content/actions/automating-builds-and-tests/building-and-testing-python.md +++ b/content/actions/automating-builds-and-tests/building-and-testing-python.md @@ -11,12 +11,10 @@ versions: ghae: '*' ghec: '*' type: tutorial -hidden: true topics: - CI - Python shortTitle: Build & test Python -hasExperimentalAlternative: true --- {% data reusables.actions.enterprise-beta %} diff --git a/content/actions/automating-builds-and-tests/index.md b/content/actions/automating-builds-and-tests/index.md index 7a40d05f7776..9eac55efbe32 100644 --- a/content/actions/automating-builds-and-tests/index.md +++ b/content/actions/automating-builds-and-tests/index.md @@ -14,13 +14,14 @@ redirect_from: - /actions/language-and-framework-guides/github-actions-for-java - /actions/language-and-framework-guides/github-actions-for-javascript-and-typescript - /actions/language-and-framework-guides/github-actions-for-python + - /actions/guides/building-and-testing-nodejs-or-python + - /actions/automating-builds-and-tests/building-and-testing-nodejs-or-python children: - /about-continuous-integration - /building-and-testing-java-with-ant - /building-and-testing-java-with-gradle - /building-and-testing-java-with-maven - /building-and-testing-net - - /building-and-testing-nodejs-or-python - /building-and-testing-nodejs - /building-and-testing-powershell - /building-and-testing-python diff --git a/content/actions/migrating-to-github-actions/migrating-from-travis-ci-to-github-actions.md b/content/actions/migrating-to-github-actions/migrating-from-travis-ci-to-github-actions.md index 73b089eec899..24de0031a4b8 100644 --- a/content/actions/migrating-to-github-actions/migrating-from-travis-ci-to-github-actions.md +++ b/content/actions/migrating-to-github-actions/migrating-from-travis-ci-to-github-actions.md @@ -209,7 +209,8 @@ The concurrent jobs and workflow execution times in {% data variables.product.pr ### Using different languages in {% data variables.product.prodname_actions %} When working with different languages in {% data variables.product.prodname_actions %}, you can create a step in your job to set up your language dependencies. For more information about working with a particular language, see the specific guide: - - [Building and testing Node.js or Python](/actions/guides/building-and-testing-nodejs-or-python) + - [Building and testing Node.js](/actions/guides/building-and-testing-nodejs) + - [Building and testing Python](/actions/guides/building-and-testing-python) - [Building and testing PowerShell](/actions/guides/building-and-testing-powershell) - [Building and testing Java with Maven](/actions/guides/building-and-testing-java-with-maven) - [Building and testing Java with Gradle](/actions/guides/building-and-testing-java-with-gradle) diff --git a/pages/[versionId]/actions/automating-builds-and-tests/building-and-testing-nodejs-or-python.tsx b/pages/[versionId]/actions/automating-builds-and-tests/building-and-testing-nodejs-or-python.tsx deleted file mode 100644 index 97fab2133be3..000000000000 --- a/pages/[versionId]/actions/automating-builds-and-tests/building-and-testing-nodejs-or-python.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import PlaygroundArticlePage from 'components/playground/PlaygroundArticlePage' - -export { getServerSideProps } from 'components/playground/PlaygroundArticlePage' - -export default PlaygroundArticlePage