Skip to content

Commit

Permalink
comment out everything but static checks
Browse files Browse the repository at this point in the history
  • Loading branch information
maykathm committed Nov 19, 2024
1 parent 7431b48 commit 6350bf5
Show file tree
Hide file tree
Showing 4 changed files with 456 additions and 383 deletions.
13 changes: 9 additions & 4 deletions .github/actions/download-snap/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ runs:
env:
SNAP_REVISION: ${{ inputs.snap-revision }}
run: |
echo "snap-revision=$SNAP_REVISION" >> $GITHUB_OUTPUT
echo "SNAP_REVISION=$SNAP_REVISION" >> $GITHUB_ENV
- name: Query the Snap Store
id: query-store
if: ${{ inputs.snap-revision == '' }}
Expand All @@ -49,15 +51,18 @@ runs:
shell: bash
run: |
SNAP_REVISION=$(curl -sS --unix-socket /run/snapd.socket http://localhost/v2/find?name=${SNAP_NAME} | jq -r ".result[].channels.\"${SNAP_CHANNEL}\".revision")
echo "snap-revision=$SNAP_REVISION" >> $GITHUB_OUTPUT
echo "SNAP_REVISION=$SNAP_REVISION" >> $GITHUB_ENV
- name: Cache ${{ inputs.snap-name }}
id: cache-snap
uses: actions/cache@v4
with:
path: |
${{ inputs.snaps-dir }}/${{ inputs.snap-name }}_${{ inputs.snap-revision && inputs.snap-revision || steps.query-store.outputs.snap-revision }}.snap
${{ inputs.snaps-dir }}/${{ inputs.snap-name }}_${{ inputs.snap-revision && inputs.snap-revision || steps.query-store.outputs.snap-revision }}.assert
key: snaps/${{ inputs.snap-name }}-${{ inputs.snap-revision && inputs.snap-revision || steps.query-store.outputs.snap-revision }}
${{ inputs.snaps-dir }}/${{ inputs.snap-name }}_${{ env.SNAP_REVISION }}.snap
${{ inputs.snaps-dir }}/${{ inputs.snap-name }}_${{ env.SNAP_REVISION }}.assert
key: snaps-${{ inputs.snap-name }}-${{ inputs.snap-revision && inputs.snap-revision || steps.query-store.outputs.snap-revision }}

- name: Download ${{ inputs.snap-name }}
if: ${{ steps.cache-snap.outputs.cache-hit != 'true' }}
env:
Expand All @@ -67,4 +72,4 @@ runs:
shell: bash
run: |
mkdir -p $SNAPS_DIR
snap download --revision=$SNAP_REVISION --target-directory=$SNAPS_DIR $SNAP_NAME
snap download --revision=$SNAP_REVISION --target-directory=$SNAPS_DIR $SNAP_NAME
47 changes: 47 additions & 0 deletions .github/workflows/install-snap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@

on:
workflow_call:
inputs:
snap-name:
description: Name of the snap to install
required: true
type: string
snap-channel:
description: Name of the channel to use (mutually exclusive with revision)
default: latest/stable
type: string
snaps-dir:
description: Directory where snaps should be stored
default: snaps
type: string
snap-classic-confinement:
description: Use classic confinement
type: boolean
default: false
outputs:
snap-revision:
description: Revision of the installed snap
value: ${{ steps.download.outputs.snap-revision }}
type: string

jobs:
install-snap:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Download snap ${{ inputs.snap-name }} from the Snap Store
id: download
uses: ./.github/actions/download-snap
with:
snap-name: ${{ inputs.snap-name }}
snap-channel: ${{ inputs.snap-channel }}
snaps-dir: ${{ inputs.snaps-dir }}
- name: Install downloaded snap ${{ inputs.snap-name }}
uses: ./.github/actions/install-offline-snap
with:
snap-name: ${{ inputs.snap-name }}
snap-revision: ${{ steps.download.outputs.snap-revision }}
snap-classic-confinement: ${{ inputs.snap-classic-confinement }}
offline-snaps-dir: ${{ steps.download.outputs.offline-snaps-dir }}
168 changes: 94 additions & 74 deletions .github/workflows/static-checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,86 +35,106 @@ jobs:
run: |
git fetch origin ${{ github.base_ref }}:${{ github.base_ref }}
- name: Download and install Debian dependencies
# Github does not allow variables in "uses"; this has to be a hard-coded path
uses: ./.github/actions/download-install-debian-deps
with:
snapd-src-dir: "${{ github.workspace }}"
# - name: Download and install Debian dependencies
# # Github does not allow variables in "uses"; this has to be a hard-coded path
# uses: ./.github/actions/download-install-debian-deps
# with:
# snapd-src-dir: "${{ github.workspace }}"

# golang latest ensures things work on the edge
- name: Install the go snap
run: |
sudo snap install --classic --channel=${{ inputs.gochannel }} go
install-go:
uses: ./.github/workflows/install-snap.yaml
with:
snap-name: go
snap-channel: ${{ inputs.gochannel }}
snaps-dir: /tmp/tmp-snap-dir
snap-classic-confinement: true

- name: Install ShellCheck as a snap
run: |
sudo apt-get remove --purge shellcheck
sudo snap install shellcheck
install-shellcheck:
uses: ./.github/workflows/install-snap.yaml
with:
snap-name: shellcheck
snap-channel: latest/stable
snaps-dir: /tmp/tmp-snap-dir

- name: Get C vendoring
run: |
cd c-vendor && ./vendor.sh
# - name: Remove shellcheck
# run: sudo apt-get remove --purge shellcheck

- name: Install golangci-lint snap
run: |
sudo snap install --classic golangci-lint
# - name: Install ShellCheck as a snap
# uses: ./.github/actions/install-snap
# with:
# snap-name: shellcheck
# snap-channel: latest/stable
# snaps-dir: /tmp/tmp-snap-dir

- name: Get changed files
id: changed-files
uses: tj-actions/[email protected]
with:
path: ./
# - name: Get C vendoring
# run: |
# cd c-vendor && ./vendor.sh

- name: Save changes files
run: |
CHANGED_FILES="${{ steps.changed-files.outputs.all_changed_files }}"
echo "CHANGED_FILES=$CHANGED_FILES" >> $GITHUB_ENV
echo "The changed files found are: $CHANGED_FILES"
# - name: Install golangci-lint snap
# uses: ./.github/actions/install-snap
# with:
# snap-name: golangci-lint
# snap-channel: latest/stable
# snaps-dir: /tmp/tmp-snap-dir
# snap-classic-confinement: true

- name: Run static checks
run: |
# run gofmt checks only with the latest stable Go
if [ "${{ matrix.gochannel }}" != "latest/stable" ]; then
export SKIP_GOFMT=1
echo "Formatting checks will be skipped due to the use of Go version ${{ inputs.gochannel }}"
fi
sudo apt-get install -y python3-yamlordereddictloader
./run-checks --static
- name: Cache prebuilt indent
id: cache-indent-bin
uses: actions/cache@v4
with:
path: indent-bin
key: ${{ runner.os }}-indent-2.2.13
# - name: Get changed files
# id: changed-files
# uses: tj-actions/[email protected]
# with:
# path: ./

# build indent 2.2.13 which has this patch
# https://git.savannah.gnu.org/cgit/indent.git/commit/?id=22b83d68e9a8b429590f42920e9f473a236123cf
- name: Build indent 2.2.13
if: steps.cache-indent-bin.outputs.cache-hit != 'true'
run: |
sudo apt install texinfo autopoint
curl -O https://ftp.gnu.org/gnu/indent/indent-2.2.13.tar.xz
tar xvf indent-2.2.13.tar.xz
cd indent-2.2.13
autoreconf -if
# set prefix in case we want to pack to tar/extract into system
./configure --prefix=/opt/indent
make -j
make install DESTDIR=${{ github.workspace }}/indent-bin
find ${{ github.workspace }}/indent-bin -ls
- name: Check C source code formatting
run: |
set -x
cd cmd/
./autogen.sh
# apply formatting
PATH=${{ github.workspace }}/indent-bin/opt/indent/bin:$PATH make fmt
set +x
if [ -n "$(git diff --stat)" ]; then
git diff
echo "C files are not fomratted correctly, run 'make fmt'"
echo "make sure to have clang-format and indent 2.2.13+ installed"
exit 1
fi
# - name: Save changes files
# run: |
# CHANGED_FILES="${{ steps.changed-files.outputs.all_changed_files }}"
# echo "CHANGED_FILES=$CHANGED_FILES" >> $GITHUB_ENV
# echo "The changed files found are: $CHANGED_FILES"

# - name: Run static checks
# run: |
# # run gofmt checks only with the latest stable Go
# if [ "${{ matrix.gochannel }}" != "latest/stable" ]; then
# export SKIP_GOFMT=1
# echo "Formatting checks will be skipped due to the use of Go version ${{ inputs.gochannel }}"
# fi
# sudo apt-get install -y python3-yamlordereddictloader
# ./run-checks --static

# - name: Cache prebuilt indent
# id: cache-indent-bin
# uses: actions/cache@v4
# with:
# path: indent-bin
# key: ${{ runner.os }}-indent-2.2.13

# # build indent 2.2.13 which has this patch
# # https://git.savannah.gnu.org/cgit/indent.git/commit/?id=22b83d68e9a8b429590f42920e9f473a236123cf
# - name: Build indent 2.2.13
# if: steps.cache-indent-bin.outputs.cache-hit != 'true'
# run: |
# sudo apt install texinfo autopoint
# curl -O https://ftp.gnu.org/gnu/indent/indent-2.2.13.tar.xz
# tar xvf indent-2.2.13.tar.xz
# cd indent-2.2.13
# autoreconf -if
# # set prefix in case we want to pack to tar/extract into system
# ./configure --prefix=/opt/indent
# make -j
# make install DESTDIR=${{ github.workspace }}/indent-bin
# find ${{ github.workspace }}/indent-bin -ls

# - name: Check C source code formatting
# run: |
# set -x
# cd cmd/
# ./autogen.sh
# # apply formatting
# PATH=${{ github.workspace }}/indent-bin/opt/indent/bin:$PATH make fmt
# set +x
# if [ -n "$(git diff --stat)" ]; then
# git diff
# echo "C files are not fomratted correctly, run 'make fmt'"
# echo "make sure to have clang-format and indent 2.2.13+ installed"
# exit 1
# fi
Loading

0 comments on commit 6350bf5

Please sign in to comment.