Эх сурвалжийг харах

Merge pull request #481 from Calinou/switch-to-github-actions

Switch continuous integration from Travis CI to GitHub Actions
Aaron Franke 5 жил өмнө
parent
commit
d29fc74ae8
3 өөрчлөгдсөн 24 нэмэгдсэн , 24 устгасан
  1. 15 0
      .github/workflows/ci.yml
  2. 0 18
      .travis.yml
  3. 9 6
      format.sh

+ 15 - 0
.github/workflows/ci.yml

@@ -0,0 +1,15 @@
+name: Continuous integration
+on: [push, pull_request]
+
+jobs:
+  build:
+    runs-on: ubuntu-20.04
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v2
+
+      - name: Lint demo projects
+        run: |
+          sudo apt-get update -qq
+          sudo apt-get install -qq dos2unix recode
+          bash ./format.sh

+ 0 - 18
.travis.yml

@@ -1,18 +0,0 @@
-dist: bionic
-
-stages:
-  - build
-
-matrix:
-  include:
-    - name: Static checks (format.sh)
-      stage: build
-      os: linux
-      addons:
-        apt:
-          packages:
-            - dos2unix
-            - recode
-
-script:
-  - bash ./format.sh

+ 9 - 6
format.sh

@@ -1,18 +1,21 @@
-#!/bin/bash
+#!/usr/bin/env bash
+
+set -uo pipefail
+IFS=$'\n\t'
 
 # Loops through all text files tracked by Git.
 git grep -zIl '' |
 while IFS= read -rd '' f; do
     # Exclude csproj and hdr files.
-    if [[ $f == *"csproj" ]]; then
+    if [[ "$f" == *"csproj" ]]; then
         continue
-    elif [[ $f == *"hdr" ]]; then
+    elif [[ "$f" == *"hdr" ]]; then
         continue
     fi
     # Ensures that files are UTF-8 formatted.
-    recode UTF-8 $f 2> /dev/null
+    recode UTF-8 "$f" 2> /dev/null
     # Ensures that files have LF line endings.
-    dos2unix $f 2> /dev/null
+    dos2unix "$f" 2> /dev/null
     # Ensures that files do not contain a BOM.
     sed -i '1s/^\xEF\xBB\xBF//' "$f"
     # Ensures that files end with newline characters.
@@ -22,7 +25,7 @@ while IFS= read -rd '' f; do
 done
 
 git diff > patch.patch
-FILESIZE=$(stat -c%s patch.patch)
+FILESIZE="$(stat -c%s patch.patch)"
 MAXSIZE=5
 
 # If no patch has been generated all is OK, clean up, and exit.