actions: Split lint workflows #115
Workflow file for this run
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
on: | |
push: | |
paths-ignore: | |
- jobs/vector.nomad | |
- terraform/vector.tf | |
pull_request: | |
jobs: | |
# This name is used by status check requirement | |
before-cd-test: | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Nomad and Consul | |
run: | | |
curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add - | |
sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | |
sudo apt-get update && sudo apt-get install -y nomad consul | |
echo "nomad_version: $(nomad -v)" | |
echo "consul_version: $(consul -v)" | |
- name: Validate job files | |
run: | | |
shopt -s globstar | |
for job in **/*.nomad; do | |
nomad job validate "$job"; | |
done | |
- name: Start a Nomad Agent and a Consul agent | |
run: | | |
sudo nomad agent -dev-connect -config nomad/development.hcl &>/dev/null & | |
consul agent -dev -bootstrap &>/dev/null & | |
- name: Wait for initializing... | |
timeout-minutes: 5 | |
run: | | |
RETRY=$((SECONDS+60)) | |
until nomad node status > /dev/null; do | |
if [ $SECONDS -gt $RETRY ]; then | |
echo 'Nomad is not booted after 60 seconds, kill...' | |
if [ -n "$(pidof nomad)" ]; then sudo kill "$(pidof nomad)"; fi | |
sudo nomad agent -dev -config nomad/development.hcl &>/dev/null & | |
RETRY=$((SECONDS+60)) | |
fi | |
sleep 1 | |
done; | |
- name: Run a Nomad job | |
run: | | |
for job in jobs/development/*.nomad; do | |
nomad job run -detach "$job" | |
done | |
- name: Access MediaWiki until success | |
timeout-minutes: 5 | |
run: | | |
echo 'Waiting for http...' | |
until curl -sLfo /dev/null localhost:8080; do | |
sleep 1; done | |
- name: Test VisualEditor API | |
run: | | |
curl -sSLvo /dev/null "http://localhost:8080/api.php?action=visualeditor&page=arbitrary_page&paction=parse&wikitext=arbitrary" | |
curl -sSLvo /dev/null "http://localhost:8080/localhost/v1/" | |
- name: backup of accessing | |
if: ${{ failure() }} | |
run: | | |
echo 'Failed to connect to localhost:8080'; | |
function header { | |
line="--------------------------------------------------------" | |
echo -e "$line\n$1\n$line" | |
} | |
header "journalctl" | |
journalctl -u nomad | |
header "docker images" | |
docker image ls --no-trunc | |
header "nomad status" | |
nomad status | |
for JOB in mysql memcached fastcgi http; do | |
header "nomad job '$JOB' status" | |
nomad job status "$JOB" | |
allocs=$(nomad job status "$JOB" | awk '/Allocations/,0' | tail -n +3 | awk '{if($6=="failed")print $1}') | |
for ALLOC in $allocs; do | |
header "[$JOB] Allocation '$ALLOC' status" | |
nomad alloc status "$ALLOC"; | |
task=$(nomad alloc status -short "$ALLOC" | tail -n1 | awk '{print $1}') | |
header "[$JOB] Allocation '$ALLOC' stdout logs " | |
nomad alloc logs "$ALLOC" $task; | |
header "[$JOB] Allocation '$ALLOC' stderr logs " | |
nomad alloc logs -stderr "$ALLOC" $task; | |
done | |
done | |
curl -sSLv localhost:8080 || true |