Skip to content

Commit

Permalink
Merge pull request #69 from stuartleeks/sl/add-gh-tests
Browse files Browse the repository at this point in the history
Add GitHub tests
  • Loading branch information
stuartleeks authored Jul 1, 2021
2 parents 1cd33ad + 30f9114 commit 69feeae
Show file tree
Hide file tree
Showing 51 changed files with 1,231 additions and 190 deletions.
263 changes: 200 additions & 63 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,81 +59,26 @@ jobs:
with:
name: azdo-task-dev
path: ./output/stuartleeks-dev.devcontainer-build-run-${{ steps.build.outputs.version }}.vsix
if-no-files-found: error

- uses: actions/upload-artifact@v2
name: Create release AzDO VSIX artifact
with:
name: azdo-task
path: ./output/stuartleeks.devcontainer-build-run-${{ steps.build.outputs.version }}.vsix

test-azdo:
name: Run AzDO test
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Show version
env:
VERSION: ${{ needs.build.outputs.version }}
VERSION_SHORT: ${{ needs.build.outputs.version_short }}
run: |
echo "VERSION: $VERSION"
echo "VERSION_SHORT: $VERSION_SHORT"
- name: Download workflow artifacts
uses: actions/download-artifact@v2
with:
path: output

- name: Download release VSIX
uses: actions/download-artifact@v2
with:
name: azdo-task-dev
path: output

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
if: github.ref == 'refs/heads/main' # only need this for push (on `main`)
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Run AzDO test pipeline
uses: ./
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AZDO_TOKEN: ${{ secrets.AZDO_TOKEN }}
AZURE_DEVOPS_EXT_PAT: ${{ secrets.AZDO_TOKEN }}
AZDO_SERVICE_URL: ${{ secrets.AZDO_SERVICE_URL }}
BUILD_NUMBER: ${{ github.run_id }}
IS_PR: ${{ github.head_ref }}
BRANCH: ${{ github.ref }}
with:
imageName: ghcr.io/stuartleeks/devcontainer-build-run-devcontainer
runCmd: |
echo "Starting"
./scripts/test-azdo.sh
env: |
BUILD_NUMBER
IS_CI=1
IS_PR
BRANCH
AZDO_TOKEN
AZURE_DEVOPS_EXT_PAT
AZDO_ORG=https://dev.azure.com/stuartle
AZDO_PROJECT=AzDODevContainerBuildRunTest
AZDO_BUILD=AzDODevContainerBuildRunTest
if-no-files-found: error

release:
name: Create release
runs-on: ubuntu-latest
needs:
- test-azdo
- build
- test-gh-run-args
- test-gh-build-args
- test-gh-dockerfile-context
- test-gh-docker-from-docker-non-root
- test-gh-docker-from-docker-root
if: github.ref == 'refs/heads/main' # only create release on `main`
env:
VERSION: ${{ needs.build.outputs.version }}
Expand Down Expand Up @@ -222,7 +167,199 @@ jobs:
AZDO_PROJECT=AzDODevContainerBuildRunTest
AZDO_BUILD=AzDODevContainerBuildRunTest
#
# Jobs to test
# (ensure that any new tests are added to the `needs` section for the release job)
#

test-azdo:
name: Run AzDO test
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Show version
env:
VERSION: ${{ needs.build.outputs.version }}
VERSION_SHORT: ${{ needs.build.outputs.version_short }}
run: |
echo "VERSION: $VERSION"
echo "VERSION_SHORT: $VERSION_SHORT"
- name: Download workflow artifacts
uses: actions/download-artifact@v2
with:
path: output

- name: Download release VSIX
uses: actions/download-artifact@v2
with:
name: azdo-task-dev
path: output

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
if: github.ref == 'refs/heads/main' # only need this for push (on `main`)
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Run AzDO test pipeline
uses: ./
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AZDO_TOKEN: ${{ secrets.AZDO_TOKEN }}
AZURE_DEVOPS_EXT_PAT: ${{ secrets.AZDO_TOKEN }}
AZDO_SERVICE_URL: ${{ secrets.AZDO_SERVICE_URL }}
BUILD_NUMBER: ${{ github.run_id }}
IS_PR: ${{ github.head_ref }}
BRANCH: ${{ github.ref }}
with:
imageName: ghcr.io/stuartleeks/devcontainer-build-run-devcontainer
runCmd: |
echo "Starting"
./scripts/test-azdo.sh
env: |
BUILD_NUMBER
IS_CI=1
IS_PR
BRANCH
AZDO_TOKEN
AZURE_DEVOPS_EXT_PAT
AZDO_ORG=https://dev.azure.com/stuartle
AZDO_PROJECT=AzDODevContainerBuildRunTest
AZDO_BUILD=AzDODevContainerBuildRunTest
test-gh-run-args:
name: Run GitHub run-args test
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
if: github.ref == 'refs/heads/main' # only need this for push (on `main`)
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Run test
uses: ./
with:
subFolder: github-tests/run-args
imageName: ghcr.io/stuartleeks/devcontainer-build-run/tests/run-args
runCmd: echo $HOSTNAME && [[ $HOSTNAME == "my-host" ]]

test-gh-build-args:
name: Run GitHub build-args test
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Run test
uses: ./
with:
subFolder: github-tests/build-args
imageName: ghcr.io/stuartleeks/devcontainer-build-run/tests/build-args
runCmd: echo $BUILD_ARG_TEST && [[ $BUILD_ARG_TEST == "Hello build-args!" ]]

test-gh-dockerfile-context:
name: Run GitHub dockerfile-context test
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Run test
uses: ./
with:
subFolder: github-tests/dockerfile-context
imageName: ghcr.io/stuartleeks/devcontainer-build-run/tests/dockerfile-context
runCmd: /tmp/dummy.sh

test-gh-docker-from-docker-non-root:
name: Run GitHub docker-from-docker-non-root test
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Run test
uses: ./
with:
subFolder: github-tests/docker-from-docker-non-root
imageName: ghcr.io/stuartleeks/devcontainer-build-run/tests/docker-from-docker-non-root
runCmd: make docker-build

test-gh-docker-from-docker-root:
name: Run GitHub docker-from-docker-root test
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Run test
uses: ./
with:
subFolder: github-tests/docker-from-docker-root
imageName: ghcr.io/stuartleeks/devcontainer-build-run/tests/docker-from-docker-root
runCmd: make docker-build


# - name: fail
# run: |
# echo "::error file=app.js,line=10,col=15::Something went wrong"
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,6 @@ lib/**/*
*.vsix


output
output

.taskkey
6 changes: 0 additions & 6 deletions azdo-task/DevContainerBuildRun/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,5 @@ build-package:
test: build-package
npm test

act: build-package
act

act-verbose: build-package
act -v

ci-package:
npm run all
4 changes: 1 addition & 3 deletions azdo-task/DevContainerBuildRun/__tests__/exec.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import {
exec
} from '../src/exec'
import {exec} from '../src/exec'

describe('exec', () => {
test('non-silent returns correct output', async () => {
Expand Down
Loading

0 comments on commit 69feeae

Please sign in to comment.