Skip to content

Commit 23c5b2a

Browse files
authored
feat(ci): add shellcheck for bash code (#10)
1 parent 4251f50 commit 23c5b2a

File tree

11 files changed

+95
-52
lines changed

11 files changed

+95
-52
lines changed

.env

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
AUR_DNS=aur.archlinux.org
2+
AUR_IP=95.216.144.15
3+
AUR_PKG=emacs-gcc-wayland-devel-bin
4+
HOME=/home/pcr
5+
PKG_REL=1
6+
UPSTREAM_API=https://api.github.com/repos/flatwhatson/emacs
7+
UPSTREAM_BRANCH=pgtk-nativecomp
8+
UPSTREAM_REPO=https://github.com/flatwhatson/emacs
9+
UPSTREAM_SRC=https://raw.githubusercontent.com/flatwhatson/emacs/pgtk-nativecomp

.github/workflows/branches.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: check-branches
2+
3+
on:
4+
- pull_request
5+
6+
jobs:
7+
shellcheck:
8+
name: Shellcheck
9+
runs-on: ubuntu-20.04
10+
steps:
11+
- uses: actions/checkout@v2
12+
- name: Run ShellCheck
13+
uses: ludeeus/action-shellcheck@master
14+
with:
15+
scandir: "./ci"

.github/workflows/build.yml

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,23 @@ on:
1010
required: true
1111

1212
env:
13-
UPSTREAM_API: https://api.github.com/repos/flatwhatson/emacs
14-
UPSTREAM_BRANCH: pgtk-nativecomp
15-
UPSTREAM_REPO: https://github.com/flatwhatson/emacs
16-
UPSTREAM_SRC: https://raw.githubusercontent.com/flatwhatson/emacs/pgtk-nativecomp
13+
OLD_COMMIT_N: ${{ github.event.inputs.old_commit_n }}
14+
NEW_COMMIT_N: ${{ github.event.inputs.new_commit_n }}
1715

1816
jobs:
1917
check:
2018
runs-on: ubuntu-20.04
21-
env:
22-
OLD_COMMIT_N: ${{ github.event.inputs.old_commit_n }}
23-
NEW_COMMIT_N: ${{ github.event.inputs.new_commit_n }}
2419
steps:
2520
- name: Checkout the repo
2621
uses: actions/checkout@v2
2722
- name: Check last version
2823
run: bash ./ci/check-last-version.bash
24+
- name: Import environment variables
25+
shell: bash
26+
run: |
27+
while read line; do
28+
echo "$line" >> $GITHUB_ENV
29+
done < .env
2930
- name: Set env vars
3031
id: var
3132
run: . ./ci/set-env-vars.bash
@@ -39,12 +40,16 @@ jobs:
3940
image: mpsq/emacs-builder:latest
4041
options: --user root
4142
env:
42-
OLD_COMMIT_N: ${{ github.event.inputs.old_commit_n }}
43-
NEW_COMMIT_N: ${{ github.event.inputs.new_commit_n }}
4443
PKG_VERSION: ${{ needs.check.outputs.pkg_version }}
4544
steps:
4645
- name: Checkout the repo
4746
uses: actions/checkout@v2
47+
- name: Import environment variables
48+
shell: bash
49+
run: |
50+
while read line; do
51+
echo "$line" >> $GITHUB_ENV
52+
done < .env
4853
- name: Patch glibc
4954
run: bash ./ci/patch-glibc.bash
5055
- name: Build artifacts
@@ -57,7 +62,7 @@ jobs:
5762
with:
5863
tag_name: ${{ needs.check.outputs.pkg_version }}
5964
release_name: Release ${{ needs.check.outputs.pkg_version }}
60-
body_path: /home/pcr/body.md
65+
body_path: ${{ env.HOME }}/body.md
6166
draft: false
6267
prerelease: false
6368
- name: Upload release asset
@@ -67,7 +72,7 @@ jobs:
6772
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6873
with:
6974
upload_url: ${{ steps.create_release.outputs.upload_url }}
70-
asset_path: /home/pcr/${{ needs.check.outputs.pkg_version }}.tar.gz
75+
asset_path: ${{ env.HOME }}/${{ needs.check.outputs.pkg_version }}.tar.gz
7176
asset_name: ${{ needs.check.outputs.pkg_version }}.tar.gz
7277
asset_content_type: application/gzip
7378
- name: Push to AUR

.github/workflows/manual.yml

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,23 @@ on:
1010
required: true
1111

1212
env:
13-
UPSTREAM_API: https://api.github.com/repos/flatwhatson/emacs
14-
UPSTREAM_BRANCH: pgtk-nativecomp
15-
UPSTREAM_REPO: https://github.com/flatwhatson/emacs
16-
UPSTREAM_SRC: https://raw.githubusercontent.com/flatwhatson/emacs/pgtk-nativecomp
13+
OLD_COMMIT_N: ${{ github.event.inputs.old_commit_n }}
14+
NEW_COMMIT_N: ${{ github.event.inputs.new_commit_n }}
1715

1816
jobs:
1917
check:
2018
runs-on: ubuntu-20.04
21-
env:
22-
OLD_COMMIT_N: ${{ github.event.inputs.old_commit_n }}
23-
NEW_COMMIT_N: ${{ github.event.inputs.new_commit_n }}
2419
steps:
2520
- name: Checkout the repo
2621
uses: actions/checkout@v2
2722
- name: Check last version
2823
run: bash ./ci/check-last-version.bash
24+
- name: Import environment variables
25+
shell: bash
26+
run: |
27+
while read line; do
28+
echo "$line" >> $GITHUB_ENV
29+
done < .env
2930
- name: Set env vars
3031
id: var
3132
run: . ./ci/set-env-vars.bash
@@ -39,12 +40,16 @@ jobs:
3940
image: mpsq/emacs-builder:latest
4041
options: --user root
4142
env:
42-
OLD_COMMIT_N: ${{ github.event.inputs.old_commit_n }}
43-
NEW_COMMIT_N: ${{ github.event.inputs.new_commit_n }}
4443
PKG_VERSION: ${{ needs.check.outputs.pkg_version }}
4544
steps:
4645
- name: Checkout the repo
4746
uses: actions/checkout@v2
47+
- name: Import environment variables
48+
shell: bash
49+
run: |
50+
while read line; do
51+
echo "$line" >> $GITHUB_ENV
52+
done < .env
4853
- name: Patch glibc
4954
run: bash ./ci/patch-glibc.bash
5055
- name: Build artifacts
@@ -53,5 +58,5 @@ jobs:
5358
uses: actions/upload-artifact@v2
5459
with:
5560
name: emacs-manual-build
56-
path: /home/pcr/${{ needs.check.outputs.pkg_version }}.tar.gz
61+
path: ${{ env.HOME }}/${{ needs.check.outputs.pkg_version }}.tar.gz
5762
retention-days: 5

.ignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
!.github

Dockerfile

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@
1515
FROM archlinux:base-devel
1616

1717
COPY deps .
18+
COPY .env .
19+
20+
ENV CC="/usr/bin/clang" \
21+
CXX="/usr/bin/clang++" \
22+
CPP="/usr/bin/clang -E" \
23+
LD="/usr/bin/lld" \
24+
AR="/usr/bin/llvm-ar" \
25+
AS="/usr/bin/llvm-as" \
26+
CFLAGS="-g -flto -fuse-ld=lld" \
27+
CXXFLAGS="-g -flto -fuse-ld=lld"
28+
29+
RUN /bin/bash -c "source .env"
1830

1931
RUN pacman -Syu --noconfirm && \
2032
pacman -U --noconfirm libgccjit-10.2.0-2-x86_64.pkg.tar.zst && \
@@ -42,28 +54,19 @@ RUN pacman -Syu --noconfirm && \
4254
jq \
4355
openssh && \
4456
groupadd -r pcr && useradd --no-log-init -r -g pcr pcr && \
45-
mkdir /home/pcr && \
46-
chown -R pcr:pcr /home/pcr && \
57+
mkdir "$HOME" && \
58+
chown -R pcr:pcr "$HOME" && \
4759
echo "pcr ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/user && \
4860
chmod 0440 /etc/sudoers.d/user
4961

50-
WORKDIR /home/pcr
62+
WORKDIR $HOME
5163

5264
COPY PKGBUILD .
5365
COPY pull.bash .
5466

55-
RUN chown -R pcr:pcr /home/pcr
67+
RUN chown -R pcr:pcr "$HOME"
5668
USER pcr
5769

58-
ENV CC="/usr/bin/clang" \
59-
CXX="/usr/bin/clang++" \
60-
CPP="/usr/bin/clang -E" \
61-
LD="/usr/bin/lld" \
62-
AR="/usr/bin/llvm-ar" \
63-
AS="/usr/bin/llvm-as" \
64-
CFLAGS="-g -flto -fuse-ld=lld" \
65-
CXXFLAGS="-g -flto -fuse-ld=lld"
66-
6770
RUN ["./pull.bash"]
6871
RUN makepkg && \
6972
rm emacs-1-1-x86_64.pkg.tar.zst

PKGBUILD

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ source=()
1010
sha1sums=()
1111

1212
build() {
13-
cd /home/pcr/emacs
13+
cd "$HOME"/emacs
1414

1515
[[ -x configure ]] || ( ./autogen.sh git && ./autogen.sh autoconf )
1616

@@ -42,7 +42,8 @@ build() {
4242
}
4343

4444
package() {
45-
cd /home/pcr/emacs
45+
cd "$HOME"/emacs
46+
4647
make DESTDIR="$pkgdir" install
4748

4849
mv "$pkgdir"/usr/bin/{ctags,ctags.emacs}

ci/build-artifacts.bash

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
set -euxo pipefail
44

5-
cd /home/pcr
5+
cd "$HOME"
66

77
# Get sources
8-
cp /__w/emacs-gcc-wayland-devel-builder/emacs-gcc-wayland-devel-builder/pull.bash pull.bash
9-
cp /__w/emacs-gcc-wayland-devel-builder/emacs-gcc-wayland-devel-builder/PKGBUILD PKGBUILD
8+
cp "$GITHUB_WORKSPACE"/pull.bash pull.bash
9+
cp "$GITHUB_WORKSPACE"/PKGBUILD PKGBUILD
1010
./pull.bash
1111
chown -R pcr:pcr emacs
1212

@@ -23,7 +23,7 @@ tar czf "$PKG_VERSION".tar.gz -C out .
2323
# Get release body
2424
delta=$(echo "$NEW_COMMIT_N - $OLD_COMMIT_N" | bc)
2525
echo -en "# Commits since last release\n\n" > body.md
26-
echo -en "Check [upstream]("$UPSTREAM_REPO"/commits) for the full history.\n\n" >> body.md
26+
echo -en "Check [upstream]($UPSTREAM_REPO/commits) for the full history.\n\n" >> body.md
2727

2828
# Get the list of commits since last release
2929
curl -s "$UPSTREAM_API"/commits?per_page="$delta" | \

ci/check-last-version.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
set -euxo pipefail
44

55
# Check if a new release is needed
6-
if ["$OLD_COMMIT_N" == "$NEW_COMMIT_N" ]; then exit 1; else exit 0; fi
6+
if [ "$OLD_COMMIT_N" == "$NEW_COMMIT_N" ]; then exit 1; else exit 0; fi

ci/push-to-aur.bash

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
#!/usr/bin/env bash
22

33
set -euxo pipefail
4+
# Needed for "mygit" alias
45
shopt -s expand_aliases
56

67
# Checksum artifacts
7-
cd /home/pcr
8+
cd "$HOME"
89
sum=$(sha512sum "$PKG_VERSION".tar.gz | sed -r 's/(.*)\s\s.*/\1/')
910

1011
# Setup SSH
@@ -13,22 +14,23 @@ mkdir .ssh
1314
echo "$PUB_KEY" | tr -d '\r' > .ssh/id_aur.pub
1415
echo "$PRIV_KEY" | base64 --decode > .ssh/id_aur
1516
chmod 600 .ssh/id_aur
16-
echo -en 'Host aur.archlinux.org\n IdentityFile /root/.ssh/id_aur\n User aur\n' > .ssh/config
17-
ssh-keyscan aur.archlinux.org > .ssh/known_hosts
18-
ssh-keyscan 95.216.144.15 >> .ssh/known_hosts
17+
echo -en 'Host '"$AUR_DNS"'\n IdentityFile /root/.ssh/id_aur\n User aur\n' > .ssh/config
18+
ssh-keyscan "$AUR_DNS" > .ssh/known_hosts
19+
ssh-keyscan "$AUR_IP" >> .ssh/known_hosts
1920

2021
# Setup git
2122
alias mygit="git -c user.name=Méril\ Pilon -c user.email=me@mpsq.org"
22-
mygit clone ssh://aur.archlinux.org/emacs-gcc-wayland-devel-bin.git
23-
mv emacs-gcc-wayland-devel-bin /home/pcr
24-
chown -R pcr:pcr /home/pcr/emacs-gcc-wayland-devel-bin
25-
cd /home/pcr/emacs-gcc-wayland-devel-bin
23+
mygit clone ssh://"$AUR_DNS"/"$AUR_PKG".git
24+
mv "$AUR_PKG" "$HOME"
25+
chown -R pcr:pcr "$HOME"/"$AUR_PKG"
26+
cd "$HOME"/"$AUR_PKG"
2627

2728
# Amend package, set pkgver, sha512 sum and pkgrel + fix permissions
28-
sed -i -r -e 's~pkgver=.*~pkgver='$PKG_VERSION'~' PKGBUILD
29+
sed -i -r -e 's~pkgver=.*~pkgver='"$PKG_VERSION"'~' PKGBUILD
2930
sed -i -r -e 's~sha512sums=.*~sha512sums=\("'"$sum"'"\)~' PKGBUILD
30-
sed -i -r -e 's/pkgrel=.*/pkgrel=1/' PKGBUILD
31+
sed -i -r -e 's~pkgrel=.*~pkgrel='"$PKG_REL"'~' PKGBUILD
3132

33+
# Cleanup + fix permissions
3234
rm .SRCINFO
3335
su pcr -c "makepkg --printsrcinfo" > .SRCINFO
3436
chown -R pcr:pcr .SRCINFO

0 commit comments

Comments
 (0)