aboutsummaryrefslogtreecommitdiffstats
path: root/.gitea/workflows/ci.yaml
blob: a5e2ca98916febf970ec89f68363a702ea39ee41 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
name: CI Pipeline

on:
  push:
    branches: [ main, master ]
  pull_request:
    branches: [ main, master ]
  workflow_dispatch:

jobs:
  shasums:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Run shasums script
        run: |
          cp -rv ./hyperterm/ "$HOME/.hyperterm/"
          cp -v .bash* "$HOME"
          cp -v ./hyperterm/_custom.sh "$HOME"
          rm -rfv hyperterm/
          (cd "$HOME/.hyperterm/" && sha512sum -c hyperterm.sha512)
          (cd "$HOME" && bash -x .bashrc)

  build:
    runs-on: ubuntu-latest
    needs: shasums
    steps:
      - uses: actions/checkout@v4

      - name: Set up locales
        run: |
          sudo apt-get update -y
          sudo apt-get install -y locales less
          sudo sed -i 's/# \(es_ES.UTF-8 UTF-8\)/\1/' /etc/locale.gen
          sudo sed -i 's/# \(en_US.UTF-8 UTF-8\)/\1/' /etc/locale.gen
          sudo locale-gen es_ES.UTF-8
          export LANG=es_ES.UTF-8 LANGUAGE=es_ES

      - name: Install dependencies for shellcheck
        run: sudo apt-get install -y xz-utils shellcheck

      - name: Run shellcheck on bash profile
        run: |
          shellcheck .bash_profile
          shellcheck ./hyperterm/hyperterm.sh
          shellcheck ./hyperterm/_custom.sh

      - name: Run shellcheck on build script
        run: shellcheck build.sh

      - name: Run build script
        run: bash -x build.sh

      - name: Run shellcheck on core scripts
        run: |
          shellcheck hyperterm/core/autocomplete.sh
          shellcheck hyperterm/core/colors.sh
          shellcheck hyperterm/core/git.sh
          shellcheck hyperterm/core/languages.sh
          shellcheck hyperterm/core/status.sh
          shellcheck hyperterm/core/update.sh

      - name: Run shellcheck on theme scripts
        run: |
          shellcheck hyperterm/themes/default.sh
          shellcheck hyperterm/themes/joy.sh
          shellcheck hyperterm/themes/light_theme.sh
          shellcheck hyperterm/themes/minterm.sh
          shellcheck hyperterm/themes/pure.sh
          shellcheck hyperterm/themes/simple.sh
          shellcheck hyperterm/themes/special.sh

      - name: Run shellcheck on tools scripts
        run: |
          shellcheck hyperterm/tools/aliases.sh
          shellcheck hyperterm/tools/compress.sh
          shellcheck hyperterm/tools/export.sh
          shellcheck hyperterm/tools/listuser.sh
          shellcheck hyperterm/tools/network.sh
          shellcheck hyperterm/tools/proxy.sh
          shellcheck hyperterm/tools/rar2zip.sh
          shellcheck hyperterm/tools/ruby.sh
          shellcheck hyperterm/tools/ssh-agent.sh
          shellcheck hyperterm/tools/sysinfo.sh
          shellcheck hyperterm/tools/virtualenv.sh

      - name: Run shellcheck on test scripts
        run: |
          shellcheck tests/test_prompt.sh
          shellcheck tests/quick_test.sh

      - name: Run shellcheck on install script
        run: shellcheck install.sh

      - name: Run install script
        run: bash -x install.sh -s

      - name: Run shellcheck on uninstall script
        run: shellcheck uninstall.sh

      - name: Run uninstall script
        run: bash -x uninstall.sh -s

  tests:
    runs-on: ubuntu-latest
    needs: build
    env:
      CI: true
    steps:
      - uses: actions/checkout@v4

      - name: Set up git configuration for tests
        run: |
          git config --global user.name "CI Test User"
          git config --global user.email "ci-test@example.com"

      - name: Install dependencies
        run: |
          sudo apt-get update -y
          sudo apt-get install -y git bash

      - name: Run quick prompt test
        run: |
          echo "INFO: Running quick prompt test"
          bash tests/quick_test.sh

      - name: Run comprehensive prompt test
        run: |
          echo "INFO: Running comprehensive prompt test"
          # Run in non-interactive mode for CI
          bash tests/test_prompt.sh --non-interactive

      - name: Test prompt in current repository
        run: |
          echo "INFO: Testing prompt in current git repository"
          # Create test changes to verify git status detection
          echo "test change for CI" >> README.md
          echo "untracked CI test file" > ci_test_file.txt

          # Test using our quick test (which already handles sourcing correctly)
          echo "Running quick test to verify prompt works in CI environment..."
          bash tests/quick_test.sh

      - name: Validate optimizations
        run: |
          echo "INFO: Validating optimizations"

          # Check that git_optimized.sh doesn't exist (should be integrated into git.sh)
          if [[ -f "hyperterm/core/git_optimized.sh" ]]; then
            echo "ERROR: git_optimized.sh should not exist (should be integrated)"
            exit 1
          fi

          # Check that git.sh exists and is optimized
          if [[ ! -f "hyperterm/core/git.sh" ]]; then
            echo "ERROR: git.sh not found"
            exit 1
          fi

          # Verify the optimized functions exist using bash
          if ! bash -c 'source hyperterm/core/git.sh && command -v _get_git_status_fast >/dev/null 2>&1'; then
            echo "ERROR: Optimized function _get_git_status_fast not found"
            exit 1
          fi

          echo "SUCCESS: Optimizations validated"

  performance:
    runs-on: ubuntu-latest
    needs: tests
    steps:
      - uses: actions/checkout@v4

      - name: Set up git configuration
        run: |
          git config --global user.name "Performance Test"
          git config --global user.email "perf-test@example.com"

      - name: Performance benchmark
        run: |
          echo "INFO: Running performance benchmark using existing test suite"

          # The comprehensive test already includes performance testing
          # Run it again to get performance metrics in CI logs
          bash tests/test_prompt.sh --non-interactive

          echo "INFO: Performance benchmark completed"
          echo "NOTE: Detailed performance metrics are included in the comprehensive test output above"