mirror of
				https://github.com/speed47/spectre-meltdown-checker.git
				synced 2025-10-31 04:30:57 +01:00 
			
		
		
		
	👷 add a fancy GitHub action for 'shellcheck' and 'shfmt' 👷 moved 'shellcheck' and 'check indentation' to new GitHub Action 🚨 fix 'shellcheck' warnings 🚨 fix 'shfmt' warnings
		
			
				
	
	
		
			82 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			YAML
		
	
	
	
	
	
			
		
		
	
	
			82 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			YAML
		
	
	
	
	
	
| name: Shellcheck, Shfmt and execution test
 | |
| 
 | |
| on:
 | |
|   push:
 | |
|     paths:
 | |
|       # Run workflow on every push
 | |
|       # only if a file within the specified paths has been changed:
 | |
|       - '*.sh'
 | |
|   # Allows you to run this workflow manually from the Actions tab
 | |
|   workflow_dispatch:
 | |
| 
 | |
| jobs:
 | |
|   sh-checker:
 | |
|     name: Shfmt Lint
 | |
|     runs-on: ubuntu-latest
 | |
|     steps:
 | |
|       - uses: actions/checkout@v1
 | |
|       - name: Run the sh-checker
 | |
|         uses: luizm/action-sh-checker@master
 | |
|         env:
 | |
|           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
 | |
|           SHELLCHECK_OPTS: -e SC1091,SC1090 # exclude some shellcheck warnings.
 | |
|           SHFMT_OPTS: -s # arguments to shfmt.
 | |
|         with:
 | |
|           sh_checker_comment: true
 | |
| 
 | |
|   check-execution:
 | |
|     runs-on: ubuntu-latest
 | |
|     steps:
 | |
|     - uses: actions/checkout@v1
 | |
|     - name: install prerequisites
 | |
|       run: sudo apt-get update && sudo apt-get install -y jq sqlite3 iucode-tool
 | |
|     - name: check direct execution
 | |
|       run: |
 | |
|         expected=15
 | |
|         nb=$(sudo ./spectre-meltdown-checker.sh --batch json | jq '.[]|.CVE' | wc -l)
 | |
|         if [ "$nb" -ne "$expected" ]; then
 | |
|           echo "Invalid number of CVEs reported: $nb instead of $expected"
 | |
|           exit 1
 | |
|         else
 | |
|           echo "OK $nb CVEs reported"
 | |
|         fi
 | |
|     - name: check docker-compose run execution
 | |
|       run: |
 | |
|         expected=15
 | |
|         docker-compose build
 | |
|         nb=$(docker-compose run --rm spectre-meltdown-checker --batch json | jq '.[]|.CVE' | wc -l)
 | |
|         if [ "$nb" -ne "$expected" ]; then
 | |
|           echo "Invalid number of CVEs reported: $nb instead of $expected"
 | |
|           exit 1
 | |
|         else
 | |
|           echo "OK $nb CVEs reported"
 | |
|         fi
 | |
|     - name: check docker run execution
 | |
|       run: |
 | |
|         expected=15
 | |
|         docker build -t spectre-meltdown-checker .
 | |
|         nb=$(docker run --rm --privileged -v /boot:/boot:ro -v /dev/cpu:/dev/cpu:ro -v /lib/modules:/lib/modules:ro spectre-meltdown-checker --batch json | jq '.[]|.CVE' | wc -l)
 | |
|         if [ "$nb" -ne "$expected" ]; then
 | |
|           echo "Invalid number of CVEs reported: $nb instead of $expected"
 | |
|           exit 1
 | |
|         else
 | |
|           echo "OK $nb CVEs reported"
 | |
|         fi
 | |
|     - name: check fwdb update
 | |
|       run: |
 | |
|         nbtmp1=$(find /tmp 2>/dev/null | wc -l)
 | |
|         ./spectre-meltdown-checker.sh --update-fwdb; ret=$?
 | |
|         if [ "$ret" != 0 ]; then
 | |
|           echo "Non-zero return value: $ret"
 | |
|           exit 1
 | |
|         fi
 | |
|         nbtmp2=$(find /tmp 2>/dev/null | wc -l)
 | |
|         if [ "$nbtmp1" != "$nbtmp2" ]; then
 | |
|           echo "Left temporary files!"
 | |
|           exit 1
 | |
|         fi
 | |
|         if ! [ -e ~/.mcedb ]; then
 | |
|           echo "No .mcedb file found after updating fwdb"
 | |
|           exit 1
 | |
|         fi
 |