Skip to content

Commit

Permalink
feat: artifacts upload support (#41)
Browse files Browse the repository at this point in the history
* feat: added artifacts upload support

* feat: added artifacts upload support

* ci: added artifact integration test

* ci: added artifact integration test

* chore: update README.md

* ci: added artifact integration test with multiple folders

* ci: added artifact integration test with multiple folders

* ci: added artifact integration test with multiple folders

* ci: added artifact integration test with multiple folders

* ci: added artifact integration test with multiple folders

* ci: added artifact integration test with multiple folders

* chore: bump version to 0.9.0

* ci: removed ls command i ntest

* ci: added artifacts name support

* ci: rename artifacts variables names to use dash syntax

* Update README.md

Co-authored-by: James Henry <[email protected]>

* Update README.md

Co-authored-by: James Henry <[email protected]>

Co-authored-by: James Henry <[email protected]>
Co-authored-by: Miroslav Jonaš <[email protected]>
  • Loading branch information
3 people authored Nov 8, 2022
1 parent 681bab0 commit 731048d
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: CI - integration test artifacts multiple folders

on:
push:
branches:
- main
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.event.number || github.ref }}
cancel-in-progress: true

jobs:
main:
name: Nx Cloud - Main Job
uses: ./.github/workflows/nx-cloud-main.yml
with:
working-directory: ./integration-tests/npm
parallel-commands-on-agents: |
npx nx run react-app:test --ci --coverage
npx nx run react-app:build
artifacts-path: |
./integration-tests/npm/dist/
./integration-tests/npm/coverage/
artifacts-name: custom-artifacts-name

agents:
name: Nx Cloud - Agents
uses: ./.github/workflows/nx-cloud-agents.yml
with:
working-directory: ./integration-tests/npm
number-of-agents: 1

check-artifact:
needs: main
runs-on: ubuntu-latest
steps:
- name: "Downloading artifacts"
uses: actions/download-artifact@v3
with:
name: custom-artifacts-name
- run: node -e "if(fs.existsSync('dist/apps/react-app') && fs.existsSync('coverage/apps/react-app')) console.log('Artifacts are here...'); else { throw new Error('Artifacts do not exist!');}"
39 changes: 39 additions & 0 deletions .github/workflows/ci-integration-test-artifacts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: CI - integration test artifacts

on:
push:
branches:
- main
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.event.number || github.ref }}
cancel-in-progress: true

jobs:
main:
name: Nx Cloud - Main Job
uses: ./.github/workflows/nx-cloud-main.yml
with:
working-directory: ./integration-tests/npm
parallel-commands-on-agents: |
npx nx run react-app:build
artifacts-path: ./integration-tests/npm/dist/

agents:
name: Nx Cloud - Agents
uses: ./.github/workflows/nx-cloud-agents.yml
with:
working-directory: ./integration-tests/npm
number-of-agents: 1

check-artifact:
needs: main
runs-on: ubuntu-latest
steps:
- name: "Downloading artifacts"
uses: actions/download-artifact@v3
with:
name: nx-main-artifacts
path: dist
- run: node -e "if(fs.existsSync('dist/apps/react-app')) console.log('Artifacts are here...'); else { throw new Error('Artifacts do not exist!');}"
15 changes: 15 additions & 0 deletions .github/workflows/nx-cloud-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ on:
required: false
type: string
default: ubuntu-latest
artifacts-path:
required: false
type: string
default: ""
artifacts-name:
required: false
type: string
default: "nx-main-artifacts"
# We needed this input in order to be able to configure out integration tests for this repo, it is not documented
# so as to not cause confusion/add noise, but technically any consumer of the workflow can use it if they want to.
working-directory:
Expand Down Expand Up @@ -319,3 +327,10 @@ jobs:
# It's important that we always run this step, otherwise in the case of any failures in preceding non-Nx steps, the agents will keep running and waste billable minutes
if: ${{ always() }}
run: npx nx-cloud stop-all-agents

- name: Uploading artifacts
uses: actions/upload-artifact@v3
if: ${{ inputs.artifacts-path != '' }}
with:
name: ${{ inputs.artifacts-name }}
path: ${{ inputs.artifacts-path }}
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<p style="text-align: center;"><img src=".github/assets/nx.png"
<p style="text-align: center;"><img src=".github/assets/nx.png"
width="100%" alt="Nx - Smart, Extensible Build Framework"></p>

<h1 align="center">Nx Cloud Github Workflows</h1>
Expand Down Expand Up @@ -208,6 +208,20 @@ jobs:
# NOTE: If you change this option, make sure it matches the agent configuration
# Default: ubuntu-latest
runs-on: ""

# [OPTIONAL] If you want to upload artifacts, please provide the paths as are required by the
# [upload-artifact](https://github.com/actions/upload-artifact) action. The name of the artifacts
# will be the value of the `artifacts-name` input.
#
# NOTE: To download your artifact in another job you need to use the [download-artifact](https://github.com/actions/download-artifact) action
# Default: ""
artifacts-path: ""

# [OPTIONAL] Provide the name of uploaded artifacts.
#
# NOTE: This input only has an effect if used with the `artifacts-path` input.
# Default: "nx-main-artifacts"
artifacts-name: ""
```
<!-- end configuration-options-for-the-main-job -->
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"private": true,
"version": "0.8.1",
"version": "0.9.0",
"description": "This package.json is here purely to control the version of the Action, in combination with https://github.com/JamesHenry/publish-shell-action"
}

0 comments on commit 731048d

Please sign in to comment.