Refactor entire project (#39)
- Use more modern TypeScript conventions - Use JavaScript Kubernetes Client - Add unit tests - Add integration tests - Add TypeScript compile verify workflow - Switch codeowners
This commit is contained in:
2
.github/CODEOWNERS
vendored
2
.github/CODEOWNERS
vendored
@ -1 +1 @@
|
||||
* @ds-ms
|
||||
* @Azure/aks-atlanta
|
||||
|
@ -1,10 +1,7 @@
|
||||
---
|
||||
name: 'Issue: Bug Report / Feature Request'
|
||||
name: "Issue: Bug Report / Feature Request"
|
||||
about: Create a report to help us improve
|
||||
title: ''
|
||||
title: ""
|
||||
labels: need-to-triage
|
||||
assignees: 'shigupt202'
|
||||
|
||||
assignees: "@Azure/aks-atlanta"
|
||||
---
|
||||
|
||||
|
||||
|
33
.github/workflows/TriggerIntegrationTests.sh
vendored
33
.github/workflows/TriggerIntegrationTests.sh
vendored
@ -1,33 +0,0 @@
|
||||
token=$1
|
||||
commit=$2
|
||||
repository=$3
|
||||
prNumber=$4
|
||||
frombranch=$5
|
||||
tobranch=$6
|
||||
patUser=$7
|
||||
|
||||
getPayLoad() {
|
||||
cat <<EOF
|
||||
{
|
||||
"event_type": "K8sSetContextPR",
|
||||
"client_payload":
|
||||
{
|
||||
"action": "K8sSetContext",
|
||||
"commit": "$commit",
|
||||
"repository": "$repository",
|
||||
"prNumber": "$prNumber",
|
||||
"tobranch": "$tobranch",
|
||||
"frombranch": "$frombranch"
|
||||
}
|
||||
}
|
||||
EOF
|
||||
}
|
||||
|
||||
response=$(curl -u $patUser:$token -X POST https://api.github.com/repos/Azure/azure-actions-integration-tests/dispatches --data "$(getPayLoad)")
|
||||
|
||||
if [ "$response" == "" ]; then
|
||||
echo "Integration tests triggered successfully"
|
||||
else
|
||||
echo "Triggering integration tests failed with: '$response'"
|
||||
exit 1
|
||||
fi
|
35
.github/workflows/default-labels.yml
vendored
Normal file
35
.github/workflows/default-labels.yml
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
name: Setting Default Labels
|
||||
|
||||
# Controls when the action will run.
|
||||
on:
|
||||
schedule:
|
||||
- cron: "0 0/3 * * *"
|
||||
|
||||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
|
||||
jobs:
|
||||
build:
|
||||
# The type of runner that the job will run on
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
# Steps represent a sequence of tasks that will be executed as part of the job
|
||||
steps:
|
||||
- uses: actions/stale@v3
|
||||
name: Setting Issue as Idle
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
stale-issue-message: "This issue is idle because it has been open for 14 days with no activity."
|
||||
stale-issue-label: "idle"
|
||||
days-before-stale: 14
|
||||
days-before-close: -1
|
||||
operations-per-run: 100
|
||||
exempt-issue-labels: "backlog"
|
||||
|
||||
- uses: actions/stale@v3
|
||||
name: Setting PR as Idle
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
stale-pr-message: "This PR is idle because it has been open for 14 days with no activity."
|
||||
stale-pr-label: "idle"
|
||||
days-before-stale: 14
|
||||
days-before-close: -1
|
||||
operations-per-run: 100
|
154
.github/workflows/integration-tests.yml
vendored
154
.github/workflows/integration-tests.yml
vendored
@ -1,19 +1,143 @@
|
||||
name: "Trigger Integration tests"
|
||||
name: Run Integration Tests
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
- 'releases/*'
|
||||
jobs:
|
||||
trigger-integration-tests:
|
||||
name: Trigger Integration tests
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out repository
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
path: IntegrationTests
|
||||
|
||||
- name: Trigger Test run
|
||||
run: |
|
||||
bash ./IntegrationTests/.github/workflows/TriggerIntegrationTests.sh ${{ secrets.L2_REPO_TOKEN }} ${{ github.event.pull_request.head.sha }} ${{ github.repository }} ${{ github.event.pull_request.number }} ${{ github.event.pull_request.head.ref }} ${{ github.event.pull_request.base.ref }} ${{ secrets.L2_REPO_USER }}
|
||||
- "releases/*"
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- "releases/*"
|
||||
|
||||
jobs:
|
||||
kubeconfig-method-integration-test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Source Code
|
||||
id: checkout-code
|
||||
uses: actions/checkout@v2
|
||||
- name: Npm Install and Build
|
||||
id: npm-build
|
||||
run: |
|
||||
npm install
|
||||
npm run build
|
||||
- name: Set Context
|
||||
uses: ./
|
||||
with:
|
||||
method: kubeconfig
|
||||
context: exp-scratch
|
||||
kubeconfig: |
|
||||
apiVersion: v1
|
||||
clusters:
|
||||
- cluster:
|
||||
certificate-authority: fake-ca-file
|
||||
server: https://1.2.3.4
|
||||
name: development
|
||||
- cluster:
|
||||
insecure-skip-tls-verify: true
|
||||
server: https://5.6.7.8
|
||||
name: scratch
|
||||
contexts:
|
||||
- context:
|
||||
cluster: development
|
||||
namespace: frontend
|
||||
user: developer
|
||||
name: dev-frontend
|
||||
- context:
|
||||
cluster: development
|
||||
namespace: storage
|
||||
user: developer
|
||||
name: dev-storage
|
||||
- context:
|
||||
cluster: scratch
|
||||
namespace: default
|
||||
user: experimenter
|
||||
name: exp-scratch
|
||||
current-context: ""
|
||||
kind: Config
|
||||
preferences: {}
|
||||
users:
|
||||
- name: developer
|
||||
user:
|
||||
client-certificate: fake-cert-file
|
||||
client-key: fake-key-file
|
||||
- name: experimenter
|
||||
user:
|
||||
password: some-password
|
||||
username: exp
|
||||
- name: Vertify Results
|
||||
run: |
|
||||
echo "$EXPECTED_KC" > /tmp/expected_kc.json
|
||||
DIFF=$(diff <(jq -S -c . $KUBECONFIG) <(jq -S -c . /tmp/expected_kc.json))
|
||||
if [ "$DIFF" != "" ]; then exit 1; else echo -e "Kubeconfig matches expected"; fi
|
||||
env:
|
||||
EXPECTED_KC: |
|
||||
{
|
||||
"apiVersion": "v1",
|
||||
"clusters": [
|
||||
{
|
||||
"cluster": {
|
||||
"certificate-authority": "fake-ca-file",
|
||||
"insecure-skip-tls-verify": false,
|
||||
"server": "https://1.2.3.4"
|
||||
},
|
||||
"name": "development"
|
||||
},
|
||||
{
|
||||
"cluster": {
|
||||
"insecure-skip-tls-verify": true,
|
||||
"server": "https://5.6.7.8"
|
||||
},
|
||||
"name": "scratch"
|
||||
}
|
||||
],
|
||||
"contexts": [
|
||||
{
|
||||
"context": {
|
||||
"cluster": "development",
|
||||
"name": "dev-frontend",
|
||||
"namespace": "frontend",
|
||||
"user": "developer"
|
||||
},
|
||||
"name": "dev-frontend"
|
||||
},
|
||||
{
|
||||
"context": {
|
||||
"cluster": "development",
|
||||
"name": "dev-storage",
|
||||
"namespace": "storage",
|
||||
"user": "developer"
|
||||
},
|
||||
"name": "dev-storage"
|
||||
},
|
||||
{
|
||||
"context": {
|
||||
"cluster": "scratch",
|
||||
"name": "exp-scratch",
|
||||
"namespace": "default",
|
||||
"user": "experimenter"
|
||||
},
|
||||
"name": "exp-scratch"
|
||||
}
|
||||
],
|
||||
"current-context": "exp-scratch",
|
||||
"kind": "Config",
|
||||
"preferences": {
|
||||
},
|
||||
"users": [
|
||||
{
|
||||
"name": "developer",
|
||||
"user": {
|
||||
"client-certificate": "fake-cert-file",
|
||||
"client-key": "fake-key-file"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "experimenter",
|
||||
"user": {
|
||||
"password": "some-password",
|
||||
"username": "exp"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
41
.github/workflows/ts-build-check.yml
vendored
Normal file
41
.github/workflows/ts-build-check.yml
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
name: TypeScript Build Check
|
||||
|
||||
on: pull_request
|
||||
|
||||
jobs:
|
||||
ts-build-check:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Pull Request
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
ref: ${{github.event.pull_request.head.ref}}
|
||||
repository: ${{github.event.pull_request.head.repo.full_name}}
|
||||
path: original-pr
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 12.x
|
||||
- name: Clone and Build Pull Request
|
||||
run: |
|
||||
cp $GITHUB_WORKSPACE/original-pr/ $GITHUB_WORKSPACE/built-pr -r
|
||||
cd $GITHUB_WORKSPACE/built-pr/
|
||||
npm i
|
||||
npm run build
|
||||
- name: Compare Built Directories
|
||||
id: diff
|
||||
run: |
|
||||
DIFF=$(diff $GITHUB_WORKSPACE/original-pr/lib $GITHUB_WORKSPACE/built-pr/lib -rqiEZbwBd)
|
||||
if [ "$DIFF" != "" ]; then exit 1; else echo -e "PR contains up-to-date compiled JavaScript."; fi
|
||||
- name: Comment Unbuilt TypeScript
|
||||
if: failure() && steps.diff.outcome == 'failure'
|
||||
uses: actions/github-script@v2
|
||||
with:
|
||||
github-token: ${{secrets.GITHUB_TOKEN}}
|
||||
script: |
|
||||
github.issues.createComment({
|
||||
issue_number: ${{ github.event.number }},
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
body: 'Please compile the TypeScript code with `npm run build`. The compiled JavaScript is not up-to-date.'
|
||||
})
|
21
.github/workflows/unit-tests.yml
vendored
21
.github/workflows/unit-tests.yml
vendored
@ -1,21 +1,20 @@
|
||||
name: "Run L0 tests."
|
||||
on: # rebuild any PRs and main branch changes
|
||||
name: Run Unit Tests
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
- 'releases/*'
|
||||
- "releases/*"
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- 'releases/*'
|
||||
- "releases/*"
|
||||
|
||||
jobs:
|
||||
build: # make sure build/ci works properly
|
||||
unit-test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
|
||||
- name: Run L0 tests.
|
||||
run: |
|
||||
npm install
|
||||
npm test
|
||||
- uses: actions/checkout@v1
|
||||
- name: Run Unit Tests
|
||||
run: |
|
||||
npm install
|
||||
npm test
|
||||
|
Reference in New Issue
Block a user