Update README.md #41
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Goodnotes CI Task | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build-and-test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Setup KinD Cluster | |
run: | | |
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.14.0/kind-$(uname)-amd64 | |
chmod +x ./kind | |
./kind create cluster --config ./config/cluster.yaml | |
- name: Disable IPv6 | |
run: | | |
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1 | |
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1 | |
sudo sysctl -w net.ipv6.conf.lo.disable_ipv6=1 | |
- name: Configuration, tools and dependencies | |
run: | | |
# sudo apt update && sudo apt upgrade -y | |
sudo apt install siege -y | |
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" | |
chmod +x ./kubectl | |
sudo mv ./kubectl /usr/local/bin/kubectl | |
chmod +x ./scripts/*.sh | |
- name: Deploy Applications and Ingress | |
run: | | |
kubectl apply -f ./config/deployment-bar.yaml | |
kubectl apply -f ./config/deployment-foo.yaml | |
kubectl apply -f ./config/ingress.yaml | |
sleep 15 | |
- name: Deploy Ingress Controller | |
run: kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/kind/deploy.yaml | |
- name: Wait for Deployments | |
run: | | |
sleep 15 | |
kubectl wait --for=condition=available --timeout=300s deployment/ingress-nginx-controller -n ingress-nginx | |
kubectl wait --for=condition=available --timeout=300s deployment/bar | |
kubectl wait --for=condition=available --timeout=300s deployment/foo | |
- name: Load Testing | |
run: | | |
bash ./scripts/load-test.sh | |
cat load-test-results.txt | |
# cat foo-load-test-results.txt | |
# cat bar-load-test-results.txt | |
# - name: test | |
# if: github.event_name == 'pull_request' | |
# uses: actions/github-script@v6 | |
# with: | |
# script: | | |
# const output = fs.readFileSync('load-test-results.txt', 'utf8'); | |
# github.issues.createComment({ | |
# issue_number: context.issue.number, | |
# owner: context.repo.owner, | |
# repo: context.repo.repo, | |
# body: `Load Test Results: TEST}` | |
# }); | |
- name: test | |
uses: actions/github-script@v3 | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
script: | | |
github.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: '👋 Thanks for reporting!' | |
}) | |
- name: Encode Load Test Results | |
run: | | |
echo "load_results=$(cat load-test-results.txt | base64 -w 0)" >> $GITHUB_ENV | |
- name: Post Results to PR | |
if: github.event_name == 'pull_request' | |
uses: actions/github-script@v6 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | |
with: | |
script: | | |
const output = Buffer.from(process.env.load_results, 'base64').toString('utf8'); | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: `Load Test Results:\n\`\`\`\n${output}\n\`\`\`` | |
}); | |
- name: Post Results to PR | |
if: github.event_name == 'pull_request' | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const output = fs.readFileSync('load-test-results.txt', 'utf8'); | |
github.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: `Load Test Results:\n${output}` | |
}); | |
# - name: Post Results to PR | |
# if: github.event_name == 'pull_request' | |
# env: | |
# GH_TOKEN: ${{ secrets.GH_TOKEN }} | |
# run: | | |
# # Read load test results | |
# output=$(cat load-test-results.txt) | |
# # Use GitHub API to post the results as a comment | |
# curl -s -X POST -H "Authorization: token ${GH_TOKEN}" -H "Accept: application/vnd.github.v3+json" \ | |
# "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.number }}/comments" \ | |
# -d "{\"body\": \"Load Test Results:\n\`\`\`\n${output}\n\`\`\`\"}" |